Docker

Docker Compose

Concept Docker Compose enable us to manage multi container environments in a file. Install As of Dec.2021 On Ubuntu 20.04 V2 https://docs.docker.com/compose/cli-command/#install-on-linux $ mkdir -p ~/.docker/cli-plugins/ $ curl -SL https://github.com/docker/compose/releases/download/v2.0.1/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose $ chmod +x ~/.docker/cli-plugins/docker-compose $ docker compose version Docker Compose version v2.0.1 Sample: php-fpm with Nginx Directory structure $ tree . ├── README.md ├── docker-compose.yml ├── front-php │ └── Dockerfile └── nginx_conf  └── front.conf docker-compose.yml:

kind - local Kubernetes cluster using Docker container nodes

My environment Pop!_OS $ uname -a Linux system76 5.11.0-7620-generic #21~1624379747~20.10~3abeff8-Ubuntu SMP Wed Jun 23 02:23:59 UTC x86_64 x86_64 x86_64 GNU/Linux Set up pre-requirements for kind Install latest Go cd /usr/local/src sudo curl -L -O https://golang.org/dl/go1.16.5.linux-amd64.tar.gz tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz export PATH=$PATH:/usr/local/go/bin /etc/profile PATH=/usr/local/go/bin:$PATH Rootless Docker Refer to my post. Install kubectl https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/#install-using-native-package-management sudo apt install -y apt-transport-https ca-certificates curl sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.

Rootless Docker

My environment Pop!_OS $ uname -a Linux system76 5.11.0-7620-generic #21~1624379747~20.10~3abeff8-Ubuntu SMP Wed Jun 23 02:23:59 UTC x86_64 x86_64 x86_64 GNU/Linux Configure rootless Docker https://docs.docker.com/engine/security/rootless/ $ dockerd-rootless-setuptool.sh install [ERROR] Missing system requirements. Run the following commands to [ERROR] install the requirements and run this tool again. ########## BEGIN ########## sudo sh -eux <<EOF # Install newuidmap & newgidmap binaries apt-get install -y uidmap EOF ########## END ########## OK… Run the command above and try again.

GitLab on Docker

Install GitLab running on Docker Here is the official document. I followed it. Caution: I’m using my GitLab on VM, not Docker image. Because the official image doesn’t contain e-mail client, and it is a little bit hard to understand. For me, deploying it on premise or VM is easy. Install docker apt install -y docker.io Set path export GITLAB_HOME=/srv/gitlab Configurations and repositories would be stored in this path. Run a container sudo docker run --detach \ --hostname {{ your_hostname }} \ --publish 443:443 --publish 80:80 --publish 2222:22 \ --name gitlab \ --restart always \ --volume $GITLAB_HOME/config:/etc/gitlab \ --volume $GITLAB_HOME/logs:/var/log/gitlab \ --volume $GITLAB_HOME/data:/var/opt/gitlab \ gitlab/gitlab-ce:latest I changed git port to 2222 because the server should be access by ssh.

ENTRYPOINT or CMD

TL;DR Best practice: When your Docker container runs as a daemon, write entrypoint.sh and run it when container starts by ENTRYPOINT. CMD can be overwritten. When ENTRYPOINT, not CMD Suppose you want to run a command when the Docker container starts. In that case, you can use CMD. The following code runs the command sleep 5 when the container starts. FROMUbuntuCMD sleep 5# or# CMD ["sleep", "5"]The arguments of CMD can be replaced when its run time command by:

Docker network

Check your network When you deploy your docker container with port mapping, the network is automatically generated and the container assigned its own network. atlex@ ~ % docker network ls NETWORK ID NAME DRIVER SCOPEea37d3b97d11 bridge bridge local01573b79ea81 host host local85b9bca4df78 none null local0abac39fbea3 dockerfiletest bridge local`Details atlex@ ~ % docker network inspect dockerfiletest[ { "Name": "dockerfiletest_default", "Id": "0abac39fbea3f9fd55c1bf9ce1288b5623b3905c3ebd2ff9e60393bab8357a24", "Created": "2020-04-15T15:52:24.875480173Z", "Scope": "local", "Driver": "bridge", "EnableIPv6": false, "IPAM": { "Driver": "default", "Options": null, "Config": [ { "Subnet": "172.

Dockerfile

Terminology context: A build’s context is the set of files located in the specified PATH or URL1. Dockerfile sample FROMubuntu:20.04ENV TZ=America/Los_AngelesRUN mkdir -p /home/my_userCOPY ./files/in_home /home/my_user/in_homeARG DEBIAN_FRONTEND=noninteractive RUN apt update && apt upgrade -yRUN apt install -y nginx phpCOPY ./files/nginx/my.conf /etc/nginx/sites-available/my.confRUN ln -s /etc/nginx/sites-available/my.conf /etc/nginx/sites-enabled/my.confCMD ["nginx", "-g", "daemon off;"]Here is the context. . ├── Dockerfile └── files ├── in_home(dir) └── nginx └── my.conf Exec the commands below and run

Docker - intro

Install macOS Environment: macOS 10.15.3 (Intel chip), Mar. 2020. Installing Docker in macOS, the official document seems to recommend installing Docker Desktop with the installer. I don’t need desktop function so far, but this is not so critical when I learn Docker. And it is the easiest way to install Docker CLI in macOS. If you don’t have DockerID, please make it first. Related official Documents: https://docs.docker.com/docker-for-mac/install/ https://hub.