Skip to content

Instantly share code, notes, and snippets.

@yagoernandes
Forked from thedarkzeno/docker.md
Last active January 23, 2020 02:57
Show Gist options
  • Select an option

  • Save yagoernandes/9020a44141fccb6dd005d94c84f4dd0e to your computer and use it in GitHub Desktop.

Select an option

Save yagoernandes/9020a44141fccb6dd005d94c84f4dd0e to your computer and use it in GitHub Desktop.
Docker commands

Docker

Installing

run in the terminal:

curl -fsSL htpps://get.docker.com/ | sh

It will download the latest version (not recommended for deployment in your server, you should stay on a stable version)

Check the version

docker --version

Hello World

run in the terminal:

docker run hello-world

If it's the first time running the hello-world docker will pull the image from docker hub

after it's ready it should print

Hello from Docker.

Useful commands

  • To check the images just run
dock images
  • To check running containers run
docker ps
  • To check all containers run
docker ps -a
  • to run an interactive terminal of a container
docker run -ti yourimagename
  • to run the container in the background
docker run -d yourimagename
  • choose the version of image
docker run yourimagename:version
  • exiting the container

Press ctrl + d

  • exit the container, but keep it running

press ctrl+p+q

  • enter in a running container
docker attach containerID
  • create container without executing it
docker create imagename
  • stopping a container
docker stop containerID
  • pausing container
docker pause containerID
  • unpausing container
docker unpause containerID
  • container stats
docker stats containerID
  • container processes
docker top containerID
  • container logs
docker logs containerID
  • remove container
docker rm containerID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment