Ubuntu 18.04: Install Docker for container

This article will describe installing Docker. Please see here for usage of Docker.

1 Install Docker

Install packages which are needed for adding docker-ce repository.

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

Add docker-ce repository. The docker-ce for bionic is not prepared yet on 2018/05/13. Use docker-ce for artful.

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
    sudo apt-key add -
$ V=artful #V=$(lsb_release -cs)
$ sudo add-apt-repository \
    "deb [arch=amd64] https://download.docker.com/linux/ubuntu ${V} stable"
$ sudo apt update -y

Install docker-ce.

$ sudo apt install -y docker-ce

Add user to docker group. Added user can run docker command without sudo command.

$ sudo gpasswd -a "${USER}" docker
$ sudo reboot

2 Execution result

Run hello-world.

$ docker run hello-world
<snip>
Hello from Docker!
<snip>