*ARGS.TECH | BLOG | Start working with Docker
Loading...
BLOG
Start working with Docker

A container is an isolated environment for your code. This means that a container has no knowledge of your operating system, or your files. It runs on the environment provided to you by Docker Desktop. Containers have everything that your code needs in order to run, down to a base operating system. You can use Docker Desktop to manage and explore your containers. Official documentation.


This article - popular docker commands collection.


If you need to show subcommands list you may see Docker help. Just call "docker" command in terminal:

user@localhost:~$ docker

Usage:  docker [OPTIONS] COMMAND

A self-sufficient runtime for containers

Options:
      --config string      Location of client config files (default "/home/xinit/.docker")
  -c, --context string     Name of the context to use to connect to the daemon
                           (overrides DOCKER_HOST env var and default context set with
                           "docker context use")
  -D, --debug              Enable debug mode
  -H, --host list          Daemon socket(s) to connect to
  -l, --log-level string   Set the logging level
                           ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
      --tls                Use TLS; implied by --tlsverify
      --tlscacert string   Trust certs signed only by this CA (default
                           "/home/xinit/.docker/ca.pem")
      --tlscert string     Path to TLS certificate file (default
                           "/home/xinit/.docker/cert.pem")
      --tlskey string      Path to TLS key file (default "/home/xinit/.docker/key.pem")
      --tlsverify          Use TLS and verify the remote
  -v, --version            Print version information and quit

Management Commands:
  builder     Manage builds
  buildx*     Docker Buildx (Docker Inc., v0.14.0)
  completion  Generate the autocompletion script for the specified shell
  config      Manage Docker configs
  container   Manage containers
  context     Manage contexts
  image       Manage images
  manifest    Manage Docker image manifests and manifest lists
  network     Manage networks
  node        Manage Swarm nodes
  plugin      Manage plugins
  secret      Manage Docker secrets
  service     Manage services
  stack       Manage Docker stacks
  swarm       Manage Swarm
  system      Manage Docker
  trust       Manage trust on Docker images
  volume      Manage volumes

Commands:
  attach      Attach local standard input, output, and error streams to a running container
  build       Build an image from a Dockerfile
  commit      Create a new image from a container's changes
  cp          Copy files/folders between a container and the local filesystem
  create      Create a new container
  diff        Inspect changes to files or directories on a container's filesystem
  events      Get real time events from the server
  exec        Run a command in a running container
  export      Export a container's filesystem as a tar archive
  history     Show the history of an image
  images      List images
  import      Import the contents from a tarball to create a filesystem image
  info        Display system-wide information
  inspect     Return low-level information on Docker objects
  kill        Kill one or more running containers
  load        Load an image from a tar archive or STDIN
  login       Log in to a Docker registry
  logout      Log out from a Docker registry
  logs        Fetch the logs of a container
  pause       Pause all processes within one or more containers
  port        List port mappings or a specific mapping for the container
  ps          List containers
  pull        Pull an image or a repository from a registry
  push        Push an image or a repository to a registry
  rename      Rename a container
  restart     Restart one or more containers
  rm          Remove one or more containers
  rmi         Remove one or more images
  run         Run a command in a new container
  save        Save one or more images to a tar archive (streamed to STDOUT by default)
  search      Search the Docker Hub for images
  start       Start one or more stopped containers
  stats       Display a live stream of container(s) resource usage statistics
  stop        Stop one or more running containers
  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
  top         Display the running processes of a container
  unpause     Unpause all processes within one or more containers
  update      Update configuration of one or more containers
  version     Show the Docker version information
  wait        Block until one or more containers stop, then print their exit codes

Run 'docker COMMAND --help' for more information on a command.

To get more help with docker, check out our guides at https://docs.docker.com/go/guides/


And some subcommand have its help. Run "docker images --help" for list all arguments:

user@localhost:~$ docker images --help

Usage:  docker images [OPTIONS] [REPOSITORY[:TAG]]

List images

Options:
  -a, --all             Show all images (default hides intermediate images)
      --digests         Show digests
  -f, --filter filter   Filter output based on conditions provided
      --format string   Pretty-print images using a Go template
      --no-trunc        Don't truncate output
  -q, --quiet           Only show image IDs


Display system-wide information:

docker info

 

Pull image from Docker hub:

docker pull ubuntu

Image pulled, but not running.

 

Start downloaded image:

docker run -it --name  MyLocalUbuntu ubuntu
-it - interactive mode (open Ubuntu shell at once)
--name - giving name for container
ubuntu - name of image
When need leave from MyLocalUbuntu's shell press "CTRL + D" keys combination.

 

See list of all downloaded images with "docker images --all" command:

user@localhost:~$ docker images --all
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
ubuntu       latest    bf3dc08bfed0   10 days ago   76.2MB

 

List of containers with "docker ps --all" command:

user@localhost:~$ docker ps -a
CONTAINER ID   IMAGE     COMMAND       CREATED         STATUS                          PORTS     NAMES
6c8d4c945b2d   ubuntu    "/bin/bash"   3 minutes ago   Exited (0) About a minute ago             MyLocalUbuntu


Run container at some port:

docker run -d -p 80:8080 docker/getting-started

Here 80 - port of your host machine. 8080 - container's port.

 

Pausing container:

docker pause <container_id>


Unpause container:

docker unpause <container_id>

 

For stopping any container run:

docker container stop <container_id>

 

Force stop container:

docker kill <container_id>

 

Remove container:

docker rm <container_id>

 

Remove Docker image:

docker rmi <image_id>
Support me on Patreon
#debian #docker #linux
Top button
© *ARGS.TECH
2025
v 2.4.0