In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
What is docker?
Official document entry
In Zhihu, I can see that the thought about docker is very good: how to explain what Docker is? It's directly quoted here.
The idea of Docker comes from containers. What problems do containers solve? On a large ship, the goods can be arranged neatly. And all kinds of goods are standardized by containers, containers and containers will not affect each other. Then I don't need a ship that specializes in fruit and chemicals. As long as the goods are well packaged in a container, I can take them all away in a big ship.
Docker is a similar idea. Cloud computing is popular now, and cloud computing is like a freighter. Docker is the container.
1. Different applications may have different application environments. For example, websites developed by. Net and php depend 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 troublesome and cause some conflicts. For example, IIS and Apache access ports conflict. At this point, you need to isolate websites developed by. Net and websites developed by php. Generally speaking, we can create different virtual machines on the server and place different applications on different virtual machines, but the virtual machine overhead is relatively high. Docker can realize the function of isolating the application environment from the virtual machine, and the overhead is less than the virtual machine, which means saving money.
two。 When you develop software, you use Ubuntu, but OPS manages centos. OPS will encounter some Ubuntu-to-centos problems when transferring your software from development environment to production environment, such as: there is a special version of the database, which is supported only by Ubuntu, but not by centos. In the process of transfer, OPS has to find a way to solve this problem. At this time, if you have docker, you can directly package and transfer the development environment to the operation and maintenance staff, and the operation and maintenance staff can directly deploy the docker you gave him. And the deployment is fast.
3. In terms of server load, if you open a separate virtual machine, then the virtual machine takes up free memory, which will be used when deployed by docker.
In short, docker is the container principle.
Centos7 install docker
Install using yum (under CentOS 7)
Note: Docker requires the kernel version of the CentOS system to be higher than 3.10. check the prerequisites on this page to verify that your version of CentOS supports Docker.
# check your current kernel version uname-r # install Dockersudo yum-y install docker# to start Docker backend service sudo service docker start# test run hello-world. Since there is no hello-world image locally, an image of hello-world will be downloaded and run in the container. Sudo docker run hello-world
Install Docker using a script
# make sure that the yum package is updated to the latest sudo yum update# to execute the Docker installation script, which adds the docker.repo source and installs Docker. Curl-fsSL https://get.docker.com/ | sh# starts the Docker process sudo service docker start# verifies whether docker is installed successfully and executes a test image sudo docker run hello-world in the container
Basic operation of Docker container
# run Ubuntu image and create an interactive environment sudo docker run-it ubuntu bash# view run process sudo docker ps-a # View container image details sudo docker inspect container name # container sudo docker start container name at restart # delete existing container sudo docker rm container name
The Docker container starts the daemon process
The first method:
# enter the interactive environment sudo docker run-it ubuntu bash# and press Ctrl+P and Ctrl+Q to exit # View the running process sudo docker ps# attached to the running container sudo docker attach container name
The second method:
# enter the interactive environment sudo docker run-d ubuntu / bin/sh-c "while true; do echo hello world; sleep 1; done" # View the running process sudo docker ps# use the log command to view the running container sudo docker logs-tf-- tail 0 container name # View the process sudo docker top container name in the container # run the new process sudo docker exec-itd container name in the running container
The Docker container stops the daemon process
The first method: send a command and wait for it to stop
Sudo docker stop Container name
The second way: kill directly
Sudo docker kill Container name
Deploy static websites in Docker
Nginx deployment process to create an interactive container for mapping port 80 install Nginx installation text editor VIM create static page modify Nginx configuration file run Nginx verify website visit # New Container web Set the container port mapping ip:hostPort:containerPortsudo docker run-p 0.0.0.0 ubuntu bash# 80-- name web-I-t ubuntu bash# enter the container interactive environment # Update package apt-get update# install nginxapt-get install-y nginx# install vimapt-get install-y vim# press Ctrl+P and Ctrl+Q exit, start daemon # View daemon process sudo docker ps# view port mapping sudo docker port web# view web container process sudo docker top web# view web information Find the container IPsudo docker inspect web
Static page configuration
Summary
The above is the whole content of this article, I hope that the content of this article has a certain reference and learning value for your study or work, if you have any questions, you can leave a message and exchange, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
Whsle wholesale Cheap discount,Authentic Authentic Jordan 1 Shoes Discount Authentic Air Jordan Shoe
© 2024 shulou.com SLNews company. All rights reserved.