
Docker introduction
Docker was originally an internal project initiated by Solomon Hykes, founder of dotCloud company, during his stay in France. It is an innovation based on cloud service technology of dotCloud company for many years. It was open-source under Apache 2.0 license agreement in March 2013. The main project code is maintained on GitHub
The Docker project later joined the Linux foundation and established the open container Alliance (OCI)
Docker has received extensive attention and discussion since it was open source. So far, its GitHub project has more than 57000 stars and more than 10000 fork s
Even due to the popularity of Docker project, dotCloud decided to change its name to Docker at the end of 2013
Docker was originally developed and implemented on Ubuntu 12.04
Red Hat supports Docker from RHEL 6.5
Google also widely uses Docker in its PaaS products
Docker is developed and implemented in Go language introduced by Google. It is based on cgroup and namespace of Linux kernel and Union FS of overlay fs to encapsulate and isolate processes. It belongs to virtualization technology at the operating system level.
Because the isolated process is independent of the host and other isolated processes, it is also called a container
The initial implementation was based on LXC. After version 0.7, LXC was removed and libcontainer developed by ourselves was used instead. From version 1.11, runC and containerd were further evolved
preface
Last article AWVS14 batch vulnerability scanning Docker After it was sent out, many people left messages on the background asking how to quickly complete Docker deployment and configuration
Here is a brief summary and description
Docker Hub account registration
Official address:
https://hub.docker.com/
Enter ID, email address and password

After registration, the email will be received. Click Verify email address to activate it, and then log in to Docker Hub

Seeing such page content means that the login is successful and can be used normally

Docker installation
Install Docker under Ubuntu
Before installing Docker for the first time, you need to set up a Docker warehouse. You can install and update Docker from the warehouse
Set up warehouse
Update apt package index
apt-get update
Install apt dependency package to obtain the warehouse through HTTPS
apt-get install \ apt-transport-https \ ca-certificates \ curl \ gnupg-agent \ software-properties-common
Add Docker official GPG key
curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
Verify that you have the key with the fingerprint by searching the last 8 characters of the fingerprint
Fingerprint information: 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
apt-key fingerprint 0EBFCD88
Set up stable version warehouse
add-apt-repository \ "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/ \ $(lsb_release -cs) \ stable"
Install docker engine community
Update apt package index
apt-get update
Install the latest version of docker engine community and containerd
apt-get install docker-ce docker-ce-cli containerd.io
Test whether Docker is successfully installed. Enter the following instructions and print out the following information
root@XS10324213323:~# docker version Client: Docker Engine - Community Version: 20.10.12 API version: 1.41 Go version: go1.16.12 Git commit: e91ed57 Built: Mon Dec 13 11:45:27 2021 OS/Arch: linux/amd64 Context: default Experimental: true Server: Docker Engine - Community Engine: Version: 20.10.12 API version: 1.41 (minimum version 1.12) Go version: go1.16.12 Git commit: 459d0df Built: Mon Dec 13 11:43:36 2021 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.4.12 GitCommit: 7b11cfaabd73bb80907dd23182b9347b4245eb5d runc: Version: 1.0.2 GitCommit: v1.0.2-0-g52b36a2 docker-init: Version: 0.19.0 GitCommit: de40ad0
Common usage of Dcoker
Download Image
root@XS10324213323:~# docker pull xsgcs/awvs_xsgcs:v20220119 v20220119: Pulling from xsgcs/awvs_xsgcs 7b1a6ab2e44d: Pull complete b92844b7ec15: Pull complete f002d83165f7: Pull complete Digest: sha256:2e63c6f0cdfad4ad726c37d81f018c6a3ca2c36d2c697565ae70ed3bdb019954 Status: Downloaded newer image for xsgcs/awvs_xsgcs:v20220119 docker.io/xsgcs/awvs_xsgcs:v20220119
View mirror
root@XS10324213323:~# docker images REPOSITORY TAG IMAGE ID CREATED SIZE xsgcs/awvs_xsgcs v20220119 3331ac19197f 22 hours ago 1.23GB
Run container
root@XS10324213323:~# docker run -it -d -p 8888:3443 xsgcs/awvs_xsgcs:v20220119 fc69af56a54b836a8adf7a2823fe7af76a8b582c08649cbf9ca9b7df7d3d1c01
View container
root@XS10324213323:~# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES fc69af56a54b xsgcs/awvs_xsgcs:v20220119 "/bin/sh -c 'echo 12..." 38 seconds ago Up 36 seconds 0.0.0.0:8888->3443/tcp, :::8888->3443/tcp nifty_lamarr
Enter container
root@XS10324213323:~# docker exec -it fc69af56a54b /bin/bash root@fc69af56a54b:/# whoami root
Close the container
root@XS10324213323:~# docker stop fc69af56a54b fc69af56a54b
Start container
root@XS10324213323:~# docker start fc69af56a54b fc69af56a54b
Packaging containers into images
root@XS10324213323:~# docker commit fc69af56a54b xsgcs123:v20220120 sha256:20c86b3c4930f3e7a68954ed623e72c45b2e6c21c1858ef87cc42b53540f1539
Upload image to Docker Hub
Set mirror label
root@XS10324213323:~# docker tag xsgcs123:v20220120 xsgcs/awvstest:v20220120
xsgcs/awvstest:v20220120 is DockerHub account name / image name: tag name
Log in to Docker Hub with the account password registered in step 1
root@XS10324213323:~# docker login Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one. Username: xsgcs Password: WARNING! Your password will be stored unencrypted in /root/.docker/config.json. Configure a credential helper to remove this warning. See https://docs.docker.com/engine/reference/commandline/login/#credentials-store Login Succeeded
Push image to Docker Hub
root@XS10324213323:~# docker push xsgcs/awvstest:v20220120 The push refers to repository [docker.io/xsgcs/awvstest] 43f715ccc958: Pushed 5feaf36e7400: Mounted from xsgcs/awvs_xsgcs 13225bea83b6: Mounted from xsgcs/awvs_xsgcs 9f54eef41275: Mounted from xsgcs/awvs_xsgcs v20220120: digest: sha256:7ffe9c126d7fe86f616803779909d8afa342be672f8efe2a7a9ee425ea6a0009 size: 1166
Visit the Docker Hub to check whether there is a newly uploaded image

delete mirror
root@XS10324213323:~# docker rmi xsgcs123:v20220120 Untagged: xsgcs123:v20220120
Delete container
Stop the container before deleting it
root@XS10324213323:~# docker stop 2774825f3b7f 2774825f3b7f root@XS10324213323:~# docker rm 2774825f3b7f 2774825f3b7f
