Script to install Docker on Ubuntu 20.04


At first

Learn about scripts for building Docker environments in Ubuntu20.04.

The script you are using is published as vm-configure on github, so please download it from github or download it from here.

See the link below for the vm-configure folder configuration.


It is a script for installing OS upgrades and Docker Docker Compose required to run Docker containers on Ubuntu 20.04.

The location of the script file is in the current directory.

SCRIPT_DIR=$(dirname "$0")

/guest-share/ubuntu-20.04/os/env.conf Loading variables defined in the file.

. "env.conf"

Updating Ubuntu to the latest version.

apt dist-upgrade

You have Ein installed an older version of the Docker package and installed the latest stable version of Docker CE.

Please refer to Docker’s documentation at the link below.

Install Docker Engine on Ubuntu
apt-get remove -y docker docker-engine containerd runc
apt-get update -y 
apt-get install -y \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
curl -fsSL | sudo apt-key add -
apt-key fingerprint 0EBFCD88
add-apt-repository \
    "deb [arch=amd64] \
    $(lsb_release -cs) \
apt-get update -y
apt-get install -y docker-ce docker-ce-cli

Downloading and installing Docker Compose using the curl command.

The version of Docker Compose to download is specified in the version defined in the /guest-share/ubuntu-20.04/os/env.conf DOCKER_COMPOSE_VERSION file.

Refer to the Docker Compose documentation at the link below.

Overview of installing Docker Compose
curl -L "${DOCKER_COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

Merge definitions into /etc/sysctl.conf file/guest-share/ubuntu-20.04/os/sysctl.conf file.

sysctl=`cat "/etc/sysctl.conf"`
while read line
	sysctl=`echo "${sysctl}" | sed -e "/^${line%%=*}=.*$/d"`
done < "sysctl.conf"
echo "${sysctl}" > "/etc/sysctl.conf"
sysctl -p

/guest-share/ubuntu-20.04/os/env.conf The value defined in the HOST_NAME is set to use as the Ubuntu host name.

hostnamectl set-hostname $HOST_NAME


Defines the settings for use with

Defining the host name.


Defines the version of Docker Compose to install.



Defines the settings to be set to /etc/sysctl.conf in

The maximum map count for virtual memory is set to 262144.

If you do not set this setting, you will get an error when using Erasticsearch in a Docker container and will not be able to start properly.

vm.max_map_count = 262144

See the link below for information on building Docker containers.