Ubuntu uses docker to configure nginx

1. Introduction to Docker

Docker host (Host): the machine where the Docker program is installed (Docker is directly installed on the operating system);
Docker client (Client): connect to the Docker host for operation;
Docker warehouse (Register): used to save and package various packages The software image;
Docker image (images): the image packaged by the software; placed in the Docker warehouse.
Docker container (Container): The instance after the image is started is called a container, and a container is an application or a group of applications that run independently.

Steps to use Docker:
1. Install the Docker warehouse
2. Go to the Docker warehouse to find the image corresponding to the software
3. Use Docker to run the image, and the image will generate a Docker container
4. The start and stop of the container is the start and stop of the software

2. Install Docker

The installation command is as follows:

The installation command is as follows:
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
can also use the domestic daocloud one-click installation command:
curl -sSL https://get.daocloud.io/docker | sh

until it appears Complete!

3. Start and stop of Docker

Start the Docker command systemctl start docker
to view the version number: docker -v

root@iZwz92jchyefq3joc3wv9eZ:~# docker -v

Docker version 20.10.7, build f0df350

The next boot will automatically start systemctl enable docker

root@iZwz92jchyefq3joc3wv9eZ:~# systemctl enable docker
Synchronizing state of docker.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable docker

stop dockersystemctl stop docker

root@iZwz92jchyefq3joc3wv9eZ:~# systemctl stop docker
Warning: Stopping docker.service, but it can still be activated by:
docker.socket

Fourth, install nginx

1. Pull the latest version of the image

docker pull nginx:latest

2. View the local mirror

docker images

3. Run the container

docker run --name nginx-test -p 80:80 -d nginx

Tips:
-name nginx-test: container name.
-p 80:80: Port mapping, mapping the local port 80 to port 80 inside the container.
-d nginx: set the container to run in the background all the time

4. View the container list

docker container ls

5. Start the container

docker start nginx-test

6. Verify
insert image description here

Guess you like

Origin blog.csdn.net/weixin_54986292/article/details/132241782