This section mainly describes the configuration and push usage of Docker under Ubuntu 18.04.
The apt
source uses HTTPS to ensure that the software is not tampered with during the download process.
Therefore, we first need to add the package using HTTPS transmission and the CA certificate.
sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
In order to confirm the validity of the downloaded software package, you need to add the GPG
key of the software source
curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
Add apt source: add Docker software source to source.list
:
sudo add-apt-repository \
" deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu \
$(lsb_release -cs) \
stable"
Install Docker CE
sudo apt-get install docker-ce
Start Docker CE
sudo systemctl enable docker
sudo systemctl start docker
The docker
command uses Unix socket to communicate with the Docker engine. Only the root
user and users in the docker
group can access the Unix socket of the Docker engine. For security reasons, the root
user will not be used directly on Linux systems. Therefore, it is better to add users who need to use docker
to the docker
user group.
Create the docker
group:
sudo groupadd docker
It may be prompted that it already exists, and then follow up operations.
Add the current user to the docker
group:
sudo usermod -aG docker $USER
Exit the current terminal and log in again to test whether Docker is installed correctly:
docker run hello-world
The output is as follows:
( base) light@city:~/myRoute/k8s/app$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1 b930d010525: Pull complete
Digest: sha256:9572f7cdcee8591948c2963463447a53466950b3fc15a247fcad1917ca215a2f
Status: Downloaded newer image for hello-world:latest
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 newcontainerfrom 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/
This step may report a TSL error, just configure the domestic mirror source: daemon.json may not exist, just create it.
vi /etc/docker/daemon.json
Configure the following:
{" registry-mirrors":["https://dockerhub.azk8s.cn","https://hub-mirror.c.163.com"]}
Restart the service:
sudo systemctl daemon-reload
sudo systemctl restart docker
Register an account on Docker Hub first.
https://hub.docker.com/
We can publish the above hello-world to our account.
First, see if there is this mirror:
docker image ls
Output:
hello-world latest fce289e99eb9 13 months ago 1.84kB
Mark it into your own warehouse:
docker tag hello-world lightcity/hello-world:v1
Push to your own warehouse:
docker push lightcity/hello-world:v1
Directly this will not push up, first execute the following:
docker login
Then push again.
push up and see it in your warehouse
Recommended Posts