My own docker command memo
$ 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
$ 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 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
$ 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