In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the use of Docker to deploy a web project and packaged into an image file case, the article introduces in great detail, has a certain reference value, interested friends must read it!
After the basic introduction to docker, you can try packaging docker image and dockerfile.
Docker Mirror
Docker hub warehouse has two types of warehouses, user warehouse and top-level warehouse, user warehouse created by docker users, top-level warehouse managed by people inside docker. The image files are stored in the warehouse, so the question is, how to create an image?
How to create image
There are two ways to build a docker image:
1. Use the docker commit command.
two。 Use the docker build command and the Dockerfile file. The docker commit command is not recommended here, but a more flexible and powerful Dockerfile should be used to build the image..
1. Create a centos image
Download the official image on dockerhub by command
Docker pull centos
two。 Create a container based on centos image
View the existing images on the server by using the command docker images
By command
Docker run-dit-p 4000UR 8080 centos image name or id
Create a container based on centos image to run in the background and map port 4000 of the server to port 8080 in the container
3. Upload the jdk,tomcat installation package and web project to the image
Docker cp / usr/local/jdk installation package container name: container address docker cp / usr/local/tomcat installation package container name: container address docker cp / usr/local/web project container name: container address 1
4. Enter the container and operate
By command
Docker attach container name or id
Enter the container
The steps to install jdk and tomcat are the same as those in linux. You can treat the container as a linux virtual machine, and then start the tomcat service.
5. Verification
Enter the http:// server ip:4000 on the browser, and if the tomcat page appears, it will be successful
6. Package the container into an image
Docker commit-a "runoob.com"-m "my apache" container name or id packaged image name: label
OPTIONS description:
-a: submitted mirror author
-c: use the Dockerfile directive to create a mirror
-m: description text at the time of submission
-p: pause the container during commit.
7. Upload to your dockerhub
Log in using your Docker ID
If you do not have a Docker account, please register one with cloud.docker.com. Write down your user name.
Log in to the Docker public registry on the local computer.
Docker login
Tag mirroring
The symbol that associates the local image with the repository on the registry is username/repository:tag. This tag is optional but recommended because it is the mechanism by which the registration authority provides versions of Docker images. Give the repository and mark the context with a meaningful name, such as get-started:part2. This places the image in the get-started repository and marks it as part2.
Now, put them together to mark the image. Run docker tag image your user name, repository and tag name so that the image will be uploaded to the destination you want. The syntax of the command is:
Docker tag image username/repository:tag
For example:
Docker tag friendlyhello john/get-started:part2
Run the docker image to see the newly marked image. You can also use docker image ls. )
Docker imagesREPOSITORY TAG IMAGE ID CREATED SIZE friendlyhello latest d9e555c53008 3 minutes ago 195MB john/get-started part2 d9e555c53008 3 minutes ago 195MB python 2.7-slim 1c7128a655f6 5 days ago 183MB …
Publish an image
Upload your tag image to the repository:
Docker push username/repository:tag
8. Download the image
Once completed, the result of this upload is public. If you log in to Docker Hub, you will see the new image and its pull command.
Extract and run the image from the remote repository
From now on, you can use the docker run command to use and run your application on any machine:
Docker run-p 4000 purl 80 username/repository:tag
If the image is not available locally on the machine, Docker will be removed from the repository.
The above is all the content of the article "deploying a web project using Docker and packaging it into an image file". Thank you for reading! Hope to share the content to help you, more related 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.