Docker Images
Download image
docker pull [image-name]List images
docker imagesCreate image out of Dockerfile
docker build -t [image-name] [folder-where-Dockerfile-present][image-name] is repository name and tag followed by colon, if hostname not specified, then it points to Dockerhub
examples
ubuntu
repository: ubuntu
tag: latestubuntu:v1
repository: ubuntu
tag: v1myregistryhost:5000/fedora/httpd:v1
repository:myregistryhost:5000/fedora/httpd
tag:v1
Tag an image
docker tag [source-image-name] [target-image-name]Delete images: it deletes tag if multiple tags present
docker rmi [image-name]Docker Containers
List running container
docker container list
docker psList all containers
docker container list -a
docker ps -aCreate a container out of docker image
docker create -ti --name [container-name] [image-name]Start container
docker start -i [container-name]Create and Start new container
- It also pulls the image if is is not available locally
docker run -ti --name [container-name] [image-name]More options
--rm: automatically remove the container when it exits-p ${OUTSIDE_PORT}:${INTERNAL_PORT}:- example:
-p 8888:80 - forward docker’s internal
80port to outside at8888
- example:
-v ${OUTSIDE_FOLDER}:${MOUNT_PATH}: mountOUTSIDE_FOLDERtoMOUNT_PATHinside docker
Stop container
docker stop [container-name]Delete containers
docker rm [container-name]Create image out of container
docker commit [container-name] [image-name]Get Inside running container
docker exec -it [container-name] bashGet logs of container
docker logs [container-name]
# tail the logs
docker logs -f [container-name]Docker Publish Registry
Pushing Docker image to container registry
docker login
docker tag [image-name] {{ hostname/image-name:tag }}
docker push {{ hostname/image-name:tag }}