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…
- Find nginx images on Docker Hub
docker search nginx
- Here we pull the official mirror image
docker pull nginx
- After the download is complete, we can check the REPOSITORY image for nginx in the list of local images
docker images nginx
- 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
And then docker PS-A
-a You can view all Docker services, including those whose status is Exited
- Then open the server address in the browser, display the nginx welcome page, that is, through the Docker nginx service success
Nginx configuration
- Check out the Docker service
docker ps -a
- Enter docker to change the nginx service environment
docker exec -it docker_id bash
- Open the
/etc/nginx/nginx.conf
configure - The configuration is complete
docker restart
Restart the service
How do I copy files to docker containers
docker cp /xx/xxx.md docker_id:/xx/xxx