Install Docker23.0.1 on Centos Stream 9

Centos Stream 9 configures yum Tsinghua source, refer to my article, click to jump

Uninstall the old version related commands:

yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

1. Update the existing yum

yum update

2. Install using repository

yum install -y yum-utils

yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

delete cache package

yum clean packages

3. Install the docker engine

When the selection appears, press y

yum install docker-ce docker-ce-cli containerd.io

docker

4. Configure the Docker image accelerator:

Log in to Alibaba Cloud – search for Mirror Accelerator and get the address (this is mine, it should be different for everyone): https://yqihq9sh.mirror.aliyuncs.com

create:

sudo mkdir -p /etc/docker

Add to:
sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://yqihq9sh.mirror.aliyuncs.com"] } EOF

Service overload:

sudo systemctl daemon-reload

Restart docker:

sudo systemctl restart docker

View configuration:

cat /etc/docker/daemon.json

5. Related commands

View version docker --version

Start systemctl start docker

View status systemctl status docker

boot self-start systemctl enable docker

Restart systemctl restart docker

stop systemctl stop docker

6. Pull the image

Take fastdfs as an example to pull the image.
If the network speed is slow , download it from https://hub.docker.com/ , upload the image package to the Linux server, and docker load -i fdfs.tarload the image through .
Use docker imagesto see if it was successful

6.1 Pull the image

The latest is pulled by default, add: 1 to specify the version as 1

docker pull morunchang/fastdfs

Qu

6.2 run tracker

docker run -d --name tracker --net=host morunchang/fastdfs sh tracker.sh

6.3 run storage

docker run -d --name storage --net=host -e TRACKER_IP=机器IP:22122 -e GROUP_NAME=自定义组名 morunchang/fastdfs sh storage.sh

例如:
docker run -d --name storage --net=host -e TRACKER_IP=192.168.20.221:22122 -e GROUP_NAME=group1 morunchang/fastdfs sh storage.sh

  • The network mode used is –net=host, and the machine IP is replaced with the server IP
  • Customize the group name, that is, the storage group
  • If you want to add a new storage server, run this command again, pay attention to replace the new group name

6.4 Modify nginx configuration

Enter the storage container and modify nginx.conf

docker exec -it storage  /bin/bash

into the container

After entering the container

6.4.1 Query the installation location of Nginx

whereis nginx

look up

6.4.2 View the current Nginx process

ps aux | grep nginx

6.4.3 Modify the configuration file of Nginx

vi /etc/nginx/conf/nginx.conf

6.4.4 Modify the Nginx configuration content (modify the port to 80)

server {
    
    
        listen       80;
        server_name  localhost;
        
        location ~ /M00 {
    
    
        		# storage 实际存储图片的位置
            root /data/fast_data/data;
            ngx_fastdfs_module;
        }
}

insert image description here

Storage storage location /data/fast_data/data

6.4.5 Enter the Nginx sbin directory and reload the Nginx configuration file

cd /etc/nginx/sbin

6.4.6 Reload configuration file

./nginx -s reload

Change setting
If the error (2: No such file or directory) is reported, first specify the configuration file to start

/etc/nginx/sbin/nginx -c /etc/nginx/conf/nginx.conf

start up

6.4.7 Exit the container

exit

7. Set up the boot container

docker update --restart=always  tracker
docker update --restart=always  storage

Commonly used commands:
View local images docker images
search images docker search redis:[version number]
to pull images (the version number can be omitted, and the latest one is pulled by default) docker pull redis:[version number]
to view all image IDs: docker images -q
delete mirror docker rmi image ID
delete image docker rmi image name: version
delete all images (use with caution): docker rmi docker images -q
view running container list docker ps
view history running container list docker ps -a

Create a container docker run -it --name= a container name image name /bin/bash

  • -i: always run
  • -t: Assign terminal to receive commands
  • -name= (or space) container name
  • -d to run the container in the background,
  • Do not enter the container without adding /bin/bash

Enter the container : docker exec -it container name/bin/bash
close the container : docker stop container name
start the container : docker start container name
delete container docker rm container name (ID)
view container information : docker inspect container name
container log docker logs container ID
Exit the container docker restart container ID
to view all container IDs : docker ps -aq
delete all containers (use with caution): docker rm docker ps -aq
container boot self-start docker update --restart=always container ID

8. About uninstalling docker

systemctl stop docker
yum remove docker-ce docker-ce-cli http://containerd.io
rm -rf /var/lib/docker
rm -rf /var/lib/containerd

Guess you like

Origin blog.csdn.net/qq_44870331/article/details/129735250