Setting up Docker on Azure with Ubuntu server

Image for post
Image for post

Here are instructions to setup your own Docker on Azure with an Ubuntu server.

Build a new Ubuntu Server

Log on your Azure portal and go to Marketplace. Search for ubuntu and select a version you want.

Image for post
Image for post

Click Create.

Image for post
Image for post

Input your VM name, user name, and resource group. Select your preferred location if needed.

Image for post
Image for post

Select your preferred authentication type:

Open Terminal (on Mac) or Git Bash (on Windows) and input command ssh-keygen -t rsa -b 4096 -C “your_email@example.com.

Image for post
Image for post

Copy public key using command:

Mac: pbcopy < ~/.ssh/dockerdemo.pub
Git Bash: clip < ~/.ssh/dockerdemo.pub

Paste the public key in SSH public key field.

Image for post
Image for post
Image for post
Image for post

Click OK to go to step 2 and choose your VM size. You may start with the smallest one as you can scale it up later.

Image for post
Image for post

You can leave default settings in step 3.

Image for post
Image for post

Click OK to start deployment.

Image for post
Image for post

It will take around one minute to finish the deployment.

Image for post
Image for post

Install Docker on Ubuntu

Open the VM and note the IP address. (You may assign a sub domain name and/or make the IP static by clicking it.)

Image for post
Image for post

You can connect to Ubuntu with ssh command:

SSH Authentication: ssh username@IPAddress -i ~/.ssh/privatekey
Password Authentication: ssh username@IPAddress

Image for post
Image for post

Remove any installed Docker:

$ sudo apt-get remove docker docker-engine docker.io

Install the packages to allow apt to use repository over HTTPs:

sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common

Add Docker’s official GPG key:

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Update one more time:

$ sudo apt-get update

Install the latest version of Docker CE:

$ sudo apt-get install docker-ce

Test it:

$ sudo docker run hello-world

You should see this if everything is working properly:

$ sudo docker run hello-worldHello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://cloud.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store