Docker Installation on Ubuntu

feature image

Docker Installation on Ubuntu

https://docs.docker.com/engine/install/ubuntu/

Check Linux distro

We will use Ubuntu.

Run:

lsb_release -a

Output:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:        22.04
Codename:       jammy

Install Docker

Run:

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

Output:

[...]
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 1506 B of archives.
After this operation, 169 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://ap-east-1.ec2.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 apt-transport-https all 2.4.8 [1506 B]
[...]

Run:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update

Output:

Hit:1 http://ap-east-1.ec2.archive.ubuntu.com/ubuntu jammy InRelease
[...]

Run:

apt-cache policy docker-ce

Output:

docker-ce:
  Installed: (none)
  Candidate: 5:20.10.22~3-0~ubuntu-jammy
  Version table:
     5:20.10.22~3-0~ubuntu-jammy 500
        500 https://download.docker.com/linux/ubuntu jammy/stable amd64 Packages
[...]

Install Docker CE

Run:

sudo apt install docker-ce

Output:

Reading package lists... Done
[...]
After this operation, 384 MB of additional disk space will be used.
Do you want to continue? [Y/n] y      

Output:

Get:1 http://ap-east-1.ec2.archive.ubuntu.com/ubuntu jammy/universe amd64 pigz amd64 2.6-1 [63.6 kB]
[...]
No VM guests are running outdated hypervisor (qemu) binaries on this host.

check Docker status

Run:

sudo systemctl status docker

Output:

● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2022-12-21 15:47:32 UTC; 3s ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 1956 (dockerd)
      Tasks: 7
     Memory: 23.9M
        CPU: 250ms
     CGroup: /system.slice/docker.service
             └─1956 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Dec 21 15:47:32 ip-172-31-4-26 dockerd[1956]: time="2022-12-21T15:47:32.390191421Z" level=info msg="scheme \"unix\" not registered,>
Dec 21 15:47:32 ip-172-31-4-26 dockerd[1956]: time="2022-12-21T15:47:32.390227597Z" level=info msg="ccResolverWrapper: sending upda>
Dec 21 15:47:32 ip-172-31-4-26 dockerd[1956]: time="2022-12-21T15:47:32.390257992Z" level=info msg="ClientConn switching balancer t>
Dec 21 15:47:32 ip-172-31-4-26 dockerd[1956]: time="2022-12-21T15:47:32.440054113Z" level=info msg="Loading containers: start."
Dec 21 15:47:32 ip-172-31-4-26 dockerd[1956]: time="2022-12-21T15:47:32.620408751Z" level=info msg="Default bridge (docker0) is ass>
Dec 21 15:47:32 ip-172-31-4-26 dockerd[1956]: time="2022-12-21T15:47:32.690826412Z" level=info msg="Loading containers: done."
Dec 21 15:47:32 ip-172-31-4-26 dockerd[1956]: time="2022-12-21T15:47:32.712750576Z" level=info msg="Docker daemon" commit=42c8b31 g>
Dec 21 15:47:32 ip-172-31-4-26 dockerd[1956]: time="2022-12-21T15:47:32.712865974Z" level=info msg="Daemon has completed initializa>
Dec 21 15:47:32 ip-172-31-4-26 systemd[1]: Started Docker Application Container Engine.
Dec 21 15:47:32 ip-172-31-4-26 dockerd[1956]: time="2022-12-21T15:47:32.745453554Z" level=info msg="API listen on /run/docker.sock"

Docker command

Run:

docker

Output:

Usage:  docker [OPTIONS] COMMAND

A self-sufficient runtime for containers

Options:
      --config string      Location of client config files (default "/home/ubuntu/.docker")
[...]
Run 'docker COMMAND --help' for more information on a command.

To get more help with docker, check out our guides at https://docs.docker.com/go/guides/

If you have one server/EC2 instance only, you may want to use minikube.

,