Skip to content

Instantly share code, notes, and snippets.

@alydemah
Last active February 26, 2020 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alydemah/619ce6745a848568a5118e4252c226aa to your computer and use it in GitHub Desktop.
Save alydemah/619ce6745a848568a5118e4252c226aa to your computer and use it in GitHub Desktop.
myDocketCheatSheet

Create

docker build -t foo . && docker run -it foo

-- Windows // Make run.bat add

docker build -t foo . docker run -it foo

  • To run the file using powershell or cmd do this:

./run.bat

Run

docker-compose up

SHOW

You can find using 3 Aliasesls, ps, list like this.

sudo docker container ls sudo docker container ps sudo docker container list sudo docker ps sudo docker ps -a

You can also use give option[option].

Options -:

-a, --all Show all containers (default shows just running) -f, --filter filter Filter output based on conditions provided --format string Pretty-print containers using a Go template -n, --last int Show last created containers (includes all states) (default -1) -l, --latest Show the latest created container (includes all states) --no-trunc Don't truncate output -q, --quiet Only display numeric IDs -s, --size Display total file sizes

Options Comment
-a, --all Show all containers (default shows just running
-f, --filter filter Filter output based on conditions provided
--format string Pretty-print containers using a Go template
-n, --last int Show last created containers (includes all states) (default -1)
-l, --latest Show the latest created container (includes all states)
--no-trunc Don't truncate output
-q, --quiet Only display numeric IDs
-s, --size Display total file sizes

You can use an option like this:

sudo docker ps //Showing only running containers

sudo docker ps -a //All container (running + stopped)

sudo docker pa -l // latest

sudo docker ps -n <int valuse 1,2,3 etc>// latest number of created containers

sudo docker ps -s // Display container with size

sudo docker ps -q // Only display numeric IDs for containers

docker docker ps -a | tail -n 1 //oldest container

Container Interactions

ping another container docker exec -ti [ping from container name] ping [target container name]

Others

docker inspect [docker-image-name]

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