Table of Contents -
To manage images
docker pull IMAGE #To pull an image from dokcerhub
docker push IMAGE #To push an image to dockerhub
docker rmi IMAGE #To delete an image
docker images #To list all images
docker image prune #To delete dangling images
docker images prune -a #To remove unused images
docker build -f /path/to/Dockerfile . #Supply dokcer file from another directory
docker build github.com/creack/docker-firefox . #To build a docker image from url
docker build -t 'imagename':'tag' . #To give a tag to docker image
docker build --build-arg 'argName'='value' . #To apply argument explicitly while creating image
To manage containers
docker create imageName #To create a container from an image
docker run imageName #To create and run container from an image
docker run --name CONTAINER imageName #To create and run container from an image and assign it a name
docker run -p hostport:containerport imageName #To create and run container from an image and map a port
docker start CONTAINER #To start a container
docker stop CONTAINER #To stop a conatiner gracefully
docker kill CONTAINER #To stop a container forcefully
docker restart CONTAINER #To stop and start a container
docker pause CONTAINER #To pause a container
docker unpause CONTAINER #To resume a container
docker rm CONTAINER #To destroy a container
docker container prune #To remove stopped containers
docker cp CONTAINER:source target #To copy a file from container to host
docker cp target CONTAINER:source #To copy a file from host to container
docker exec -it CONTAINER bash #To start a shell inside running container
docker rename OLD_CONTAINER NEW_CONTAINER #To rename a container
docker commit CONTAINER #To create an image out of container
Info and stats
docker logs CONTAINER #To see the logs of running container
docker stats #To see the stats of running container
docker top CONTAINER #To show the processes of container
docker inspect NAME #To get the detailed info about an object
docker diff CONTAINER #To show all modified files in container
docker port CONTAINER #To show mapped ports to container
Command's Options
-a, --attach# attach stdout/err
-i, --interactive# attach stdin (interactive)
-t, --tty# pseudo-tty
--name NAME# name your image
-p, --publish 5000:5000# port map
--expose 5432# expose a port to linked containers
-P, --publish-all# publish all ports
--link container:alias# linking
-v, --volume `pwd`:/app # mount (absolute paths needed)
-e, --env NAME=hello# env vars
-d, --detach# run in background
All docker compose commands
docker-compose config #Validate and view the Compose file.
docker-compose down #Stops containers and removes containers, networks, volumes, and images created by up.
docker-compose exec #With this subcommand you can run arbitrary commands in your services
docker-compose help #Displays help and usage instructions for a command.
docker-compose images #List images used by the created containers.
docker-compose kill #Forces running containers to stop by sending a SIGKILL signal.
docker-compose logs #Displays log output from services.
docker-compose pause #Pauses running containers of a service
docker-compose port #Prints the public port for a port binding.
docker-compose ps #Lists containers..
docker-compose rm #Removes stopped service containers. By default, anonymous volumes attached to containers are not removed. You can override this with -v.
docker-compose start #Starts existing containers for a service.
docker-compose stop #Stops running containers without removing them. They can be started again with docker-compose start.
docker-compose top #Displays the running processes.
docker-compose unpause #Unpauses paused containers of a service.
docker-compose up #Builds, (re)creates, starts, and attaches to containers for a service.
0 comments:
Post a Comment