Today, I encountered a small problem that after starting the image, I could not access it through HTTP request. Let's record and share the solution: Common Docker startup commands and solutions are as follows: 1. Start DockerAs we all know, the command to start the container is as follows: docker run image name 2. Binding container ports to local portsAfter starting the container, the local port cannot be directly accessed, so it is necessary to bind the local port to the container port so that the container can be accessed through the local port. The settings are as follows: docker run -p local port: container port image name Then you can access the container through the local port through the local browser. 3. The container runs in the background, add the -d parameter, the command is as follows:docker run -d -p local port: container port image name 4. View the mirror list, the command is as followsdocker image ls or docker images 5. View the running container, the command is as followsdocker ps Supplement: Docker maps local ports to running containers 1. Submit the running container as an image (so that various operations in the container will not be lost)docker commit tang tang1 ### tang (name of running container) tang1 (name of generated image) 2. Run the image and add portsdocker run -d -it -p 8000:80 tang1:latest /bin/bash ### The small p is the custom port and latest is the label of the image (it is better to write something professional) Supplement: Docker loads volume and binds port RequireThe docker image has been obtained. Now you want to create a container, load the local directory into the container directory, and map the ports between the local and container. Specific examples are as follows: image ID: 884e0fc83dfe Set container name: test Map the local port 9000 to the container's port 80 Load the data volume volume: map the local ~/Desktop/test to the container's /test directory accomplishdocker run -it --name test -v ~/Desktop/test:/test -p 9000:80 884e0fc83dfe /bin/bash # Enter the new container docker start test docker attach test The above is my personal experience. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. If there are any mistakes or incomplete considerations, please feel free to correct me. You may also be interested in:
|
>>: Detailed explanation of loop usage in javascript examples
1. Overview The information_schema database is th...
Previously, the images we used were all pulled fr...
Delete a file by its inode number First use ls -i...
Solution to Host 'xxxx' is not allowed to...
On a whim, I wrote a case study of a small ball b...
This article mainly introduces several scheduling...
Table of contents Target Thought Analysis Code la...
This article shares a digital clock effect implem...
Table of contents The essence of QR code login Un...
The img tag in XHTML should be written like this:...
The Golden Rule Always follow the same set of cod...
How to modify the style of the el-select componen...
This article example shares the specific code of ...
Table of contents Preface Example summary Preface...
Preface When testing, in order to test the projec...