In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to use Docker, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Docker is an open source container engine, and its view is that different containers are installed on the server with separate cpu and configuration environment. When you need this environment, you only need to download the container separately and use it, and you can also configure your own container. This method makes it convenient for developers to save time and trouble to build a complex development environment again when changing office machines, and it takes only one second to restart the container, as shown in the following figure:
Our initial model was that all the applications were stored in the A1 server, but if one of the applications crashed because the memory was too full, then the server suffered, so the application resources needed to be independent. In this case, A2 was used, and different virtual machines were installed on one server, and each virtual machine was allocated different memory and cpu. This solves the problem of application resource independence if the application has crashed, it will not affect the content of application 2, but the virtual machine starts too slowly, and if you need to reconfigure the virtual machine when migrating the application, we can use docker to implement the third A3 mode. Docker container restart time is very fast when the application is migrated, just download the image of the docker server and run it.
Using tutorials
Here we use docker on the premise that the server is a Ubuntu system.
/ / first, install dockersudo apt-get install docker.io//. After the installation is complete, we enter docker to view the detailed command parameters.
The docker info command can help us view the information of docker.
What we need next is that the container now has a docker that is just an empty docker.
/ / first, we need a system image with the docker pull command to get the system image docker pull ubuntu:14.04// images command to see which images exist in the native docker. Then we run the image called container readable and writable run command to run the image docker run-it ubuntu:14.04//, and then we enter the container. The operation will not affect the original system exit exit container
Next, we will convert the container we have created into an image for future development.
The / / ps command can see which containers we are currently running-a parameter indicates which containers have been run-the docker ps-a//commit command is used to convert the container into an image-m parameter is used to submit the description information-a specifies the long letters and numbers of the user information to indicate the id of the container and finally specifies the user name warehouse name and tag information sudo docker commit-m "xxxx" of the target image -a "xxx" id user name / warehouse name tag information / / when we run docker images, we will find that we have just converted the image with the docker run-it user name / repository name tag information, we can run the newly converted container
Next, we need to upload the newly created container to the docker hub container repository for later reuse or use by others.
/ / first log in to docker hubdocker login//, then enter the user name, password and email, and finally return the login success prompt / / run the push command to upload the docker push user name / warehouse name tag information / / and then you can see the image you uploaded in docker hub.
Dockerfile usage
Case study: using nginx to create a web page
First, let's create a new www directory and then store an index.html file and write something at random.
Then store a file named dockerfle in the same level directory of www and write the content as
FROM ubuntu:14.04 / / declare the construction image MAINTAINER saymagic saymagic@163.com / / tell others your name and contact information RUN apt-get updateRUN apt-get install-y nginxCOPY. / www/user/share/nginx/html / / copy the current system files to the container directory EXPOSE 80 / / declare that port 80 CMD is open ["nginx", "- g", "daemon off" "] / / indicates that nginx// is enabled when the container is running. Finally, we use build to build the image and run docker build-t =" user name / warehouse name tag information ".
At this point, when we run docker images, we will see the image just generated. Now we can run the image, which is slightly different from the previous one. At this time, we need to specify port 80 externally. The behavior is specified by the-p parameter, and run.
Docker run-p 80:80 username / warehouse name tag information
At this point, the terminal will get stuck because the idea of docker is that it is best to open only one thread per container to do one thing, and now we can check the effect through localhost.
The above is all the contents of this article "how to use Docker". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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
© 2024 shulou.com SLNews company. All rights reserved.