Docker commands list that can be executed on docker host
1. docker login
provide username and password when prompted
2. docker pull dockerImageName ( here default library or registry name is "library" otherwise use syntax "username/dockerImageName", it pulls image but not run)
3. docker run -it -p 80:3000 -p 8080:3000 -v /opt/my-host-folder: /var/inside/docker/container/folder-name username/dockerImageName
here -i attach host input to docker container
-t attach host terminal to docker container to see output
-p port mapping host-port:container internal port
-v volume mapping host-volume-path: container internal volume path
4. docker run -d username/dockerImageName ( run docker in background in detached mode)
5. docker run -attach username/dockerImageName ( run docker in foreground in attached mode)
6. docker ps -a ( list all container processes running)
7. docker images ( list all docker images on docker host)
8. docker stop dockercontinerName ( stop docker container)
9. docker rm dockercontinerName ( delete docker container dockercontinerName or dockerId can be used)
10. docker rmi username/dockerImageName ( delete docker image, make sure first stop any running container of this image)
11. docker inspect dockercontinerName ( view details of docker container config like ip address port running etc.)
12. docker build Dockerfile -t username/dockerImageName ( build docker with tag as username/dockerImageName)
13. docker push username/dockerImageName ( push docker to public docker hub registry under your user, make sure you are logged in first using docker login command)
14. docker pull username/dockerImageName:source_image_tag
15. docker run --entrypoint command-name username/dockerImageName ( overwrite docker container entry point command at rum time when docker container started)
16. docker run -e ENV-VAR-NAME=VALUE username/dockerImageName ( export or set environment variable to be passed to docker container at start up)
Note: username above could be docker registry name
No comments:
Post a Comment