Skip to content

Instantly share code, notes, and snippets.

@scriptnull
Last active May 11, 2016 14:49
Show Gist options
  • Select an option

  • Save scriptnull/e0e7a58dfaa37649d5b5 to your computer and use it in GitHub Desktop.

Select an option

Save scriptnull/e0e7a58dfaa37649d5b5 to your computer and use it in GitHub Desktop.
#list all docker images currently available
docker images
#create a container to run a docker image
#if not present,it tires to pull from dockerhub
docker run hello-world
#run docker in interactive mode with pseudo tty
docker run -i -t ubuntu
#run docker in daemon mode
#docker run -d image_name command
docker run -d ubuntu /bin/sh -c "while true; do echo hello; sleep 1; done"
#run container , exposing the required ports to high ports ( 32768 to 61000 )
docker run -d -P training/webapp
#run container , exposing the required ports to specific ports
docker run -d -p 80:5000 training/webapp
#show STDOUT of a container
docker logs container_name_or_id
#show STDOUT of a container and listen for upcoming logs
docker logs -f container_name_or_id
#show on going process inside docker
docker top container_name_or_id
#inspect docker container for metadata
docker inspect container_name_or_id
#stop a running container
docker stop container_name_or_id
#remove a container , container shouldn't be running while doing this.
docker rm container_name_or_id
#show currently running docker containers
docker ps
#show last started container
docker ps -l
#show all containers with their state
docker ps -a
#show docker version
docker version
#get help for a command
#docker command --help
#building docker images
# way 1 : run an interactive container , execute whatever you want and commit it
docker commit -m "my message" -a base_image_id new_image_name
#new_image_name -> username/webapp:v2
#way 2 : use docker file
docker build -t new_image_name .
#tag an image with its last committed state
docker tag new_image_name
#push image to docker hub
docker push image_name
#pull image from docker hub
docker pull image_name
@mehradzed1
Copy link

سلام لطفا منو از ریپورتی در بیارین.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment