To publish articles is to record their own learning.Copy the code

Operating environment: MAC Installation address: docs.docker.com/docker-for-… \

Start the Nginx server

Start the Nginx server and enter the emulated terminalCopy the code

docker run -p 8080:80 --name nginx_web -it nginx /bin/bash

-p is port mapping, local port: docker starts the service from the internal port --name is to set a name for the container to be started. -I enables the container's standard input to be turned on. -t allows Docker to assign a pseudo-terminal and bind it to the standard inputCopy the code

2. Know the configuration file location of Nginx image

Log file location: / var/log/nginx configuration file location: / etc/nginx resource location: / usr/share/nginx/HTML configuration path above is the address of the virtual Linux on my computer, please readers, also to see its own configurationCopy the code

Access to Nginx services

The Nginx service we built is now accessible through port localhost:8080. Run docker exec it nginx_web /bin/bash to enter the /usr/share/nginx/html directory to place our web files under this directory. This completes a Docker-built Nginx serviceCopy the code

4, Some common docker instructions

Take a look at the container we are runningCopy the code

docker ps

Look at all the containers that have been runCopy the code

docker ps -a

Restart the container that you just startedCopy the code

docker restart nginx_web

Inside the containerCopy the code

docker attach nginx_web / docker exec -it nginx_web /bin/bash

Exit the containerCopy the code

ctrl + P + Q