Docker command summary


My own docker command memo

docker basic command

$ docker images //docker image list

$ docker run <image name>  //Make a container The container is not up at this point($ docker create <image name> + $ docker start -a <image name>command
$ docker run -d <image name> //Detached mode (moves in the background)
$ docker run --rm <image name> //One-time container
$ docker run --name <name> <image name>
$ docker run -it <image name> bash  //Start the container and overwrite it with the bash program make it inputtable and make the screen look pretty
$ docker run -it -v "Host file source path:Container path" <image name> bash //Mount the host file system on the container (not actually accessible) Example docker run-it -v ~/Desktop/docker_test/mounted_folder:/new_dir f3a01f5a7b45 bash
$ docker run -it -p <host port number>:<Container port number> --rm jupyter/datascience-notebook bash Connect the host and container port
$ docker run -it --rm  --cpus <Number of cores> --memory <memory> ubuntu bash //Example docker run-it --rm  --cpus 4 --memory 2g ubuntu bash

$ docker restart<Container name> //Bring up the container from exit
$ docker exec -it <Container name> bash //Program execution for the up container
:/# exit //Cut the process and exit the container
:/#Detach(ctrl + p + q) //The container remains up while leaving the container process
$ docker attach <Container name>//Re-enter the process of a detached container

$ docker build <directory path> //Find dockerfile in the directory and build example docker build.
$ docker build -t <name> <directory path> //Build with a name
$ docker build <dockerfile name in the path where dockerfile is located> <docker context> //If you want to build from outside the current directory

Erase related

$ docker rmi <Repository name> //image deleted
$ docker rm <Container name> //Delete container in exit state
$ docker stop <Container name> //Container up → exit
$ docker system prune //Delete all containers in exit state

docker hub related

$ docker login //Log in to docker hub
$ docker docker pull <image name> //Example ubuntu
$ docker commit <image name> <repository name(新image name):tag name> //Updated image (image name must be repository name to push)
//The repository name of dockerhub is username/<Repository name>Is the composition of
//When pushing, username/<Repository name> = <image name:tag name>Keep in the relationship
docker tag <image name of source><image name of target> //Change the image name

application? 1

$ id -u //Confirm user ID
$ id -g //Check group ID
$ docker run -it -u $(id -u):$(id -g) -v ~/Desktop/docker_test/mounted_folder:/reated_in_run <image id> bash //Run with user id
$ docker inspect <Container ID>   //Confirm cpu and memory allocation

Note: The directory mkdired with dockerfile has root privileges.

Recommended Posts

Docker command summary
[Docker] Command summary
docker command personal summary
Docker command
Docker basic summary
Memorandum docker command
Docker command list
Heroku command summary
Docker command memo
[Memo] docker summary
Docker command memorandum
[Docker] Command list
Docker Machine command memo
[Rails] rails db command summary
docker error delete command
Docker command cheat sheet
Decomposing the Docker run command. .. ..
Docker Compact Manual (1: Basic / Basic Command)
Summary of frequently used Docker commands
docker memo
Easy installation of Docker with snap (1 command)
spring × docker
Object-oriented summary
About Docker
Grant docker command execution permission to ec2-user
Command Pattern
Docker Intellij
Docker basics
Docker installation
About Docker
Docker memorandum
Try to use docker command without sudo.
ransack summary
Understand Docker
Docker memorandum
Command docker-compose
[Docker] Introduction to docker compose Basic summary of docker-compose.yml
Environment construction command memo with Docker on AWS
Command to stop or delete all Docker resources
WSL, Zsh, VSCode, Docker, NodeJS setup summary in 2020
Summary of Docker understanding by beginners ① ~ docker run -p ~