What is a docker

  • Docker is a package for Linux containers and provides an easy-to-use interface for container use. It is currently the most popular Linux container solution.
  • Docker packages the application and its dependencies in a single file. Running this file generates a virtual container. Programs run in this virtual container as if they were running on a real physical machine. With Docker you don’t have to worry about the environment.
  • Overall, Docker interface is quite simple, users can easily create and use containers, put their own applications into the container. Containers can also be versioned, copied, shared, and modified just like normal code.

Personal understanding

Different applications may have different application environments. For example, a website developed by.NET and a website developed by PHP rely on different software. If the software they rely on is installed on the same server, it will take a long time to debug, and it will be very troublesome, and will cause some conflicts. For example, IIS and Apache access ports conflict. At this point you need to separate.net sites from PHP sites. Generally speaking, we can create different virtual machines on the server and place different applications on different virtual machines, but the overhead of virtual machines is high. Docker can realize the function of virtual machine isolation application environment, and the cost is smaller than virtual machine, saving resources.

The installation

Centos:www.runoob.com/docker/cent…

The instance

Create the nginx service

Reference: www.cnblogs.com/panchanggui…

  1. Find nginx images on Docker Hubdocker search nginx
  2. Here we pull the official mirror imagedocker pull nginx
  3. After the download is complete, we can check the REPOSITORY image for nginx in the list of local imagesdocker images nginx
  4. The following command uses the default configuration of NGINX to start an NGINX container instance:
docker run --name nginx-test -p 80:80-d nginx nginx-test Container name -d sets the container in the background to always run -p port mapping to local80Port mapped inside the container80portCopy the code
  1. And then docker PS-A-a You can view all Docker services, including those whose status is Exited

  1. Then open the server address in the browser, display the nginx welcome page, that is, through the Docker nginx service success

Nginx configuration

  1. Check out the Docker servicedocker ps -a
  2. Enter docker to change the nginx service environmentdocker exec -it docker_id bash
  3. Open the/etc/nginx/nginx.confconfigure
  4. The configuration is completedocker restartRestart the service

How do I copy files to docker containers

docker cp /xx/xxx.md docker_id:/xx/xxx