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.

/guest-share/ubuntu-20.04/os/configure.sh

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")
cd "$SCRIPT_DIR"

/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
Jumpstartyourclient-sideserverapplicationswithDockerEngineonUbuntu.Thisguidedetailsprerequisitesandmultiplemethodstoinstall.
apt-get remove -y docker docker-engine docker.io containerd runc
apt-get update -y 
apt-get install -y \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
apt-key fingerprint 0EBFCD88
add-apt-repository \
    "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
    $(lsb_release -cs) \
    stable"
apt-get update -y
apt-get install -y docker-ce docker-ce-cli containerd.io

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
LearnhowtoinstallDockerCompose.ComposeisavailablenativelyonDockerDesktop,asaDockerEngineplugin,andasastandalonetool.
curl -L "https://github.com/docker/compose/releases/download/${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.

LF=$'\n'
sysctl=`cat "/etc/sysctl.conf"`
while read line
do
	sysctl=`echo "${sysctl}" | sed -e "/^${line%%=*}=.*$/d"`
	sysctl+="${LF}${line}"
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

/guest-share/ubuntu-20.04/os/env.conf

Defines the settings for use with configure.sh.

Defining the host name.

HOST_NAME=collbow.local

Defines the version of Docker Compose to install.

DOCKER_COMPOSE_VERSION=1.26.2

/guest-share/ubuntu-20.04/os/sysctl.conf

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

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.

Comment

スポンサーリンク