Development/Docker

[Docker] Install Docker Engine on Ubuntu

jstar0525 2022. 10. 21. 00:32
반응형

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

 

Install Docker Engine on Ubuntu

 

docs.docker.com

 

위 링크로 접속하면

설치하는 방법이 나와있으나,

처음 Docker를 접하는 사람들을 위하여 정리해보고자 한다.

 

Env.

테스트 환경은

Ubuntu 18.04를 설치하고

처음으로 Docker를 설치한다고 가정을 했다.

 

1. Set up the repositoty

(1) Update the apt package index and install packages to allow apt to use a repository over HTTPS:

sudo apt-get update
sudo apt-get install \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

(2) Add Docker’s official GPG key:

sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

(3) Use the following command to set up the repository:

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

 

2. Install Docker Engine

(1) Update the apt package index, and install the latest version of Docker Engine, containerd, and Docker Compose, or go to the next step to install a specific version: 

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin

(2) To install a specific version of Docker Engine, list the available versions in the repo, then select and install:

a. List the versions available in your repo:

여기서 자신에 맞는 버전을 찾는다.

apt-cache madison docker-ce

b. Install a specific version using the version string from the second column

위에서 찾은 특정 버전의 docker-ce와 docker-ce-cli를 설치한다.

sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io docker-compose-plugin

예시)

sudo apt-get install docker-ce=5:20.10.20~3-0~ubuntu-bionic docker-ce-cli=5:20.10.20~3-0~ubuntu-bionic containerd.io docker-compose-plugin

(3) Verify that Docker Engine is installed correctly by running the hello-world image.

sudo service docker start
$ sudo docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/
반응형