Site icon CentLinux

How to install Docker on Ubuntu Server 18

Share on Social Media

Learn how to install Docker on Ubuntu Server 18 with our comprehensive guide. Follow step-by-step instructions to set up Docker and start deploying containerized applications efficiently on your server. #centlinux #ubuntu #docker

What is Docker?

Docker is a set of Platform as a Service (PaaS) products that use operating system level virtualization to deliver software in packages called Containers. Containers are isolated from one another and bundle their own software, libraries and configuration files; they can communicate with each other through well-defined channels. All containers are run by a single operating-system kernel and are thus more lightweight than virtual machines. (Courtesy: Wikipedia)

The software that hosts the containers is called Docker Engine. It was initially developed in 2013 and now it is maintained by Docker, Inc.

Docker is a Freemium product and available in both Enterprise (commercial) and Community (free) editions.

Recommended Training for You: Docker for absolute beginners

Docker Features

Some of the core features of Docker are.

Docker Alternatives

If you’re looking for alternatives to Docker for containerization and orchestration, there are several other tools and platforms available that offer similar functionalities with different features and benefits. Here are some of the best Docker alternatives:

1. Podman

2. Kubernetes

3. OpenShift

4. LXC (Linux Containers)

5. CRI-O

6. rkt (Rocket)

7. containerd

8. Mesos

9. Nomad

10. Singularity

Comparing Docker Alternatives

ToolKey FeaturesSuitable For
PodmanDaemonless, rootless containers, Docker CLIDevelopment and production
KubernetesAutomated deployment, scaling, managementLarge-scale container orchestration
OpenShiftEnterprise Kubernetes, CI/CD integrationEnterprise environments
LXCLightweight, isolated Linux instancesRunning multiple Linux systems
CRI-OKubernetes integration, OCI standardsKubernetes environments
rktSecurity-focused, multiple image formatsSecurity-focused deployments
containerdHigh performance, Kubernetes integrationCore container runtime
MesosScalable resource management, container orchestrationCluster management
NomadMulti-region/cloud support, HashiCorp integrationMixed workloads and orchestration
SingularityHPC focus, rootless containersScientific and HPC environments

These alternatives offer various features that may better suit specific needs and use cases compared to Docker. Exploring these options can help you choose the best tool for your containerization and orchestration requirements.

Environment Specification

We are using a Ubuntu virtual machine with following specification.

Update your Ubuntu Server

Connect with docker-01.sysadminlabs.com as ahmer user by using a ssh tool like PuTTY.

Update existing software packages by executing apt command.

$ sudo apt update

There are some package upgrades are available. Install these upgrades by using following command.

$ sudo apt upgrade

Install Docker on Ubuntu Server

Docker is available in apt repository, therefore, you can easily install it on Ubuntu server by using a single apt command.

$ sudo apt install docker.io

Enable and start Docker service.

$ sudo systemctl enable --now docker
Synchronizing state of docker.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service â /lib/systemd/system/docker.service.

Verify version of installed Docker software.

$ docker --version
Docker version 18.09.7, build 2d0083d

Install Docker Compose on Ubuntu Server

Compose (or Docker Compose) is a software tool to define and run multi-container Docker applications. It uses YAML file to create, run and configure application services.

You can install docker-compose on your preferred Linux distro by using the following command.

$ sudo curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   617  100   617    0     0    696      0 --:--:-- --:--:-- --:--:--   695
100 16.3M  100 16.3M    0     0   551k      0  0:00:30  0:00:30 --:--:--  636k

Grant execution permissions to all users on docker-compose executable.

$ sudo chmod +x /usr/local/bin/docker-compose

Create a soft link to docker-compose command in common binary path, so the command can be accessible from anywhere.

$ sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

Execute docker-compose command to check its version.

$ sudo docker-compose --version
docker-compose version 1.25.4, build 8d51620a

Docker Compose has been installed successfully on Ubuntu Server 18.04 LTS.

Execute Basic Docker Commands

Search for Alpine Linux in Docker online registry (Docker Hub).

$ sudo docker search alpine
NAME                                   DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
alpine                                 A minimal Docker image based on Alpine Linux⦠  6038                [OK]
mhart/alpine-node                      Minimal Node.js built on Alpine Linux           453
...
roribio16/alpine-sqs                   Dockerized ElasticMQ server + web UI over Al⦠  7                                       [OK]
cfmanteiga/alpine-bash-curl-jq         Docker Alpine image with Bash, curl and jq p⦠  5                                       [OK]

Pull the image of Alpine Linux using docker command.

$ sudo docker pull alpine
Using default tag: latest
latest: Pulling from library/alpine
c9b1b535fdd9: Pull complete
Digest: sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
Status: Downloaded newer image for alpine:latest

List Docker images that are locally available on our Ubuntu 18.04 server.

$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
alpine              latest              e7d92cdc71fe        6 days ago          5.59MB

Create a Docker container in interactive mode using Alpine Linux image and execute some test commands on it.

$ sudo docker run -it --rm alpine /bin/sh
/ # uname -a
Linux 40c0683c7989 5.0.0-38-generic #41-Ubuntu SMP Tue Dec 3 00:27:35 UTC 2019 x86_64 Linux
/ # cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.11.3
PRETTY_NAME="Alpine Linux v3.11"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://bugs.alpinelinux.org/"
/ # exit

Create a Docker container in detach mode from Alpine Linux image.

$ sudo docker run -d alpine
0ad0a833a2b3e0e1c6a9735f27e8849786708d23f7c9070645d2c55650903c02

Check list of recently executed containers.

$ sudo docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS                          PORTS               NAMES
0ad0a833a2b3        alpine              "/bin/sh"           About a minute ago   Exited (0) About a minute ago                       mystifying_blackburn

Remove a container as follows.

$ sudo docker container rm 0ad0a833a2b3
0ad0a833a2b3

Remove an image that is locally available on our Ubuntu 18.04 server.

$ sudo docker rmi alpine
Untagged: alpine:latest
Untagged: alpine@sha256:ab00606a42621fb68f2ed6ad3c88be54397f981a7b70a79db3d1172b11c4367d
Deleted: sha256:e7d92cdc71feacf90708cb59182d0df1b911f8ae022d29e8e95d75ca6a99776a
Deleted: sha256:5216338b40a7b96416b8b9858974bbe4acc3096ee60acbc4dfb1ee02aecceb10

You have successfully installed Docker on Ubuntu 18.04 server and executed some basic commands thereon.  You should also read our guide on how to install Docker on CentOS 8.

If you wish to learn more about containers then you should read Docker in Action (PAID LINK) by Manning Publications.

Final Thoughts

Installing Docker on Ubuntu Server 18 is a great way to streamline your application deployment and management. With Docker, you can easily create, deploy, and run applications in containers, ensuring consistency across multiple environments.

For a detailed, step-by-step guide on how to install Docker on Ubuntu Server 18, check out my Fiverr gig: Install & Configure Docker on Ubuntu Server. I provide expert assistance to help you set up Docker efficiently and effectively.

If you have any questions or need further support, feel free to reach out!

Exit mobile version