I've been coming without touching Docker for a long time, but recently I've been trying various things, feeling the atmosphere that seems to be used for deep learning. Then, in the current project, I wanted to set up a Web server and verify it, so I decided to build an environment with Docker, so that's a memo.
By the way, I was a little addicted to mounting the directory on the host side when trying to do it in a Windows environment, so it is mainly a memo.
For this memo, I referred to the following article.
-Set up a web server with Docker and create a verification environment
Starting a container is very simple.
Start container
#Start Docker container
$ docker container run --name web -d -p 8888:80 -v $(pwd):/usr/share/nginx/html nginx:alpine
In the article I referred to, the command was written as above, but in Windows the path on the host side of the argument passed to -v
had to be described as follows.
It was written at the end of this article.
Starting a container on Windows
$ docker container run --name web -d -p 8888:80 -v D:/path/to/docker/nginx/html:/usr/share/nginx/html nginx:alpine
The meanings of the command arguments are as follows.
container #Subcommands for container operations
run #Start container
--name <container-name> #Container name
-d #Start the container in the background (d of detach)
-p <host-port>:<container-port> #Port forwarding of host port and container port
-v <host_path>:<container_path>> #Mount the host volume in a container
nginx:alpine #Image name of container
Stop and delete containers
#Stop
$ docker container stop web
#Delete
$ docker container rm web
Confirmation of mount information, etc.
$ docker inspect $(doker ps -q)
$ (docker ps -q)
will return the ID of the running container.
--Mount the host machine's directory in the Docker container / Check the mounted path
Recommended Posts