Use Docker instead of the Python virtual environment to analyze data in Python and develop web applications. I summarized the Docker basic commands.
Pull the image from Docker Hub, run the container, create the image from the container and push it to Docker Hub.
| command | Explanation |
|---|---|
| docker login | Log in to docker |
| docker pull <image> | Get image from docker hub |
| docker run -it <image> bash | Run the container from the image with a bash program. run is create+start. bash is<command>Is entered, overwriting the default command. |
| exit | Get out of the container |
| docker ps -a | Show list of containers process status.-Also displays containers stopped at a |
| docker images | Display image list |
| docker restart <container> | Reboot container status from exit to up |
| docker exec -it <container> bash | Run the container in a bash program |
| docker commit <container> <image> | Create an image from a container |
| docker tag <source> <target> | Give the image a tag name (make it the same name as the docker hub repository to upload to docker hub) |
| docker push <image> | Push to Docker Hub |
| docker rmi <image> | Delete image |
| command | Explanation |
|---|---|
| docker rm <container> | Delete container |
| docker system prune | Bulk delete containers |
| docker rmi <image> | Delete image |
| docker image prune | Delete images in bulk |
Options when starting the container.
| option | Explanation |
|---|---|
| -it | Basically use.-i can be input.-t makes the display beautiful |
| --name <container_name> <image> | Specify the container name |
| --d <image> | Detach after starting the container (run in the background) |
| --rm <image> | Delete the container after exiting (one-time container) |
| -v <host/path>:<container/path> | File system sharing |
| -u $(id -u):$(id -g) | Access to files |
| -p <host_port>:<container/port> | Connect ports |
| --cpus <#ofCPUs> --memory <byte> | Computer resource limit. Of the following command<something>Check the current situation by putting cpu etc. in |
You can find out more about the container with docker inspect <container> | grep -i <something>.
| command | Explanation |
|---|---|
| docker build <directory> | <directory>To ".Is often specified. Move to the folder where Dockerfile is saved and build in the current directory |
| docker build -t <name> <directory> | Specify the image name |
| docker build -f <docker file> <build context> | Used when the Dockerfile is not in the building context (current directory, etc.). If you have multiple Dockerfiles for development and test |
Keywords related to docker build: Docker daemon, build context
Recommended Posts