Docker Engine on Linux: Systemd Setup & User

๐Ÿ’ก Docker Engine on Linux: Systemd Setup & User โ€” Executive Summary

Technical architectural analysis, practical configuration manifests, and deployment instructions for Docker Engine on Linux: Systemd Setup & User.

RHEL
repository-setting
bash
# rhel
sudo yum install -y yum-utils
## rhel x86_64์˜ ๊ฒฝ์šฐ์—๋Š” ๋ฆฌํฌ์ง€ํ† ๋ฆฌ์—์„œ ๋ฐ›์„ ์ˆ˜ ์—†์œผ๋ฏ€๋กœ centos์šฉ repository๋ฅผ ์ด์šฉ
sudo yum-config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

# rhel-extra (version 8)
[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirror.kakao.com/centos/8/extras/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=http://mirror.kakao.com/centos/RPM-GPG-KEY-CentOS-Official
setup
bash
# ๊ธฐ์กด ์„ค์น˜๋ชฉ๋ก ์ œ๊ฑฐ
sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine \
                  podman \
                  runc

# ์ข…์†์„ฑ ์„ค์น˜: pkgs.org์—์„œ ๊ฒ€์ƒ‰ํ•˜๋ฉด ์‰ฝ๊ฒŒ ์ฐพ์„ ์ˆ˜ ์žˆ์Œ
sudo yum install -y https://vault.centos.org/centos/8/BaseOS/x86_64/os/Packages/libcgroup-0.41-19.el8.x86_64.rpm
sudo yum install -y https://vault.centos.org/centos/8/BaseOS/x86_64/os/Packages/fuse3-libs-3.2.1-12.el8.x86_64.rpm
sudo yum install -y https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/fuse-overlayfs-0.7.8-1.module_el8.5.0+1004+c00a74f5.x86_64.rpm
sudo yum install -y https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/slirp4netns-0.4.2-3.git21fdece.module_el8.5.0+1004+c00a74f5.x86_64.rpm

# docker packages
sudo yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
run
bash
sudo systemctl start docker

Settings for non-sudo users

bash
sudo usermod -aG docker $USER
newgrp docker
sudo cp /usr/bin/docker /usr/local/bin/
Ubuntu
bash
# ubuntu
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
# GPG KEY ์ถ”๊ฐ€
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# ๋ฆฌํฌ์ง€ํ† ๋ฆฌ ๋“ฑ๋ก
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
# ๋‹ค์šด๋กœ๋“œ
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
sudo systemctl status docker
MacOS (docker-desktop not used, external Docker daemon connected)
Linux server Docker external port open
bash
sudo vi /lib/systemd/system/docker.service
>>>
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
# ์œ„ ๋‚ด์šฉ์„ ์•„๋ž˜๋กœ ๋ณ€๊ฒฝ
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock -H 0.0.0.0:2376
<<<
sudo systemctl daemon-reload
sudo systemctl restart docker.service
netstat -lntp | grep 2376
Use mac Docker client (using external Docker Daemon)
bash
brew install docker docker-completion docker-compose docker-credential-helper
docker -H"$dockerDaemonProxy" images
docker -H"$dockerDaemonProxy" login $url
MacOS (colima)
bash
brew install docker docker-compose colima docker-credential-helper

vi ~/.docker/config.json
>>>
        "credsStore": "osxkeychain",
<<<
# VM์„ 4CPU ๋ฐ 8GiB ๋ฉ”๋ชจ๋ฆฌ๋กœ ์‹คํ–‰
colima start --cpu 4 --memory 8
# 1CPU, 2GiB ๋ฉ”๋ชจ๋ฆฌ ๋ฐ 10GiB ์Šคํ† ๋ฆฌ์ง€๋ฅผ ๊ฐ–์ถ˜ VM์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค.
colima start --cpu 1 --memory 2 --disk 10
# Rosetta 2 ์—๋ฎฌ๋ ˆ์ด์…˜์œผ๋กœ VM ์„ค์ •
colima start --arch aarch64 --vm-type=vz --vz-rosetta

# Docker client์˜ Endpoint ๋ชฉ๋ก์กฐํšŒ
docker context ls
# colima๋กœ Endpoint ๋ณ€๊ฒฝ
docker context use colima

# Completion
colima completion zsh >> ~/.zshrc

# template ๋ณ€๊ฒฝ: insecure ๋“ฑ
colima delete
colima template

# ์‹œ์ž‘
colima start
# ์ข…๋ฃŒ
colima stop
Download docker-credential-pass for Linux (docker login) โ€” When activated, pull is possible, but there was an unauthorized issue when pushing
References and Guidelines (NOTE)

Docker login password is encrypted rather than stored in plain text (~/.docker/config.json โ€“ base64)

bash
sudo -i
apt-get install rng-tools pass -y
rngd -r /dev/urandom
gpg --gen-key #๋‚ด์ด๋ฆ„, ์ด๋ฉ”์ผ, ์•”ํ˜ธ ์ž…๋ ฅ


#linux amd64
wget https://github.com/docker/docker-credential-helpers/releases/download/v0.6.3/docker-credential-pass-v0.6.3-amd64.tar.gz
tar xvzf docker-credential-pass-v0.6.3-amd64.tar.gz

rm docker-credential-pass-v0.6.3-amd64.tar.gz
sudo chmod a+x docker-credential-pass
sudo mv docker-credential-pass /usr/local/bin

gpg -K #sec ์˜์—ญ์˜ gpg key ๋ณต์‚ฌ
>>>
sec   rsa3072 2024-03-12 [SC] [expires: 2026-03-12]
      B01D8CA085D7FE165DFF7E04946D1238D4877BE2
uid           [ultimate] Myeonghan Kim <[email protected]>
ssb   rsa3072 2024-03-12 [E] [expires: 2026-03-12]
<<<

pass init $gpgkey
pass insert docker-credential-helpers/docker-pass-initialized-check #password ์ž…๋ ฅ
pass ls
>>>
Password Store
โ””โ”€โ”€ docker-credential-helpers
    โ””โ”€โ”€ docker-pass-initialized-check
<<<

vi ~/.docker/config.json
>>>
{
        "experimental": "enabled"
}
<<<

docker login
https authentication on client side without Dockerd Insecure
bash
mv ca.pem ~/.docker/
docker --tlsverify $commands #http response error
https authentication on server side without Dockerd Insecure
bash
vi /etc/docker/daemon.json
>>>
{
        "tlsverify": true,
        "tlscacert": "/root/.docker/tls/ca.pem",
        "tlscert": "/root/.docker/tls/cert.pem",
        "tlskey": "/root/.docker/tls/key.pem"
}
<<<
docker push #์ธ์ฆ์—๋Ÿฌ unauthorized: unauthorized to access repository: game-hosting/mc-backup, action: push: unauthorized to access repository: game-hosting/mc-backup, action: push

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *