0% found this document useful (0 votes)
22 views7 pages

Docker Basics: Containers & Commands

The document provides an overview of Docker basics, including key terminologies such as container images and the container lifecycle stages: created, running, stopped, and deleted. It outlines the syntax and parameters for the 'docker run' and 'docker exec' commands, as well as the structure of a Docker Compose manifest, which includes mandatory and optional sections. The document also details the services section of the manifest, specifying various configurations like container name, image, volumes, environment variables, ports, and restart policies.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views7 pages

Docker Basics: Containers & Commands

The document provides an overview of Docker basics, including key terminologies such as container images and the container lifecycle stages: created, running, stopped, and deleted. It outlines the syntax and parameters for the 'docker run' and 'docker exec' commands, as well as the structure of a Docker Compose manifest, which includes mandatory and optional sections. The document also details the services section of the manifest, specifying various configurations like container name, image, volumes, environment variables, ports, and restart policies.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Docker Basics

Benediktus Anindito
Cloud Computing
Terminologies

Container Image: a prebuilt template for
running container

Container: an virtual instance which has
separate namespace, operating system
libraries, which running inside a host system
Container Lifecycle

Here are lifecycle of a container
– Created: a container instance is created; ephemeral storage
is allocated; networking parameters is set; but it is not
started yet
– Running: a container instance is started and run its own
process
– Stopped: a container instance still exists but all its process is
killed.
– Deleted: a container instance is deleted and its ephemeral
storage is removed; networking parameters is also removed.
docker run basic parametes
● Syntax:
– Docker run <parameter1>…<parametern> <image-name:tag> [commandline]
● --name : set name for the new container
● -d : run in background (daemonized)
● -i : run with STDIN keep open
● -t : allocate a pseudo-TTY; usually run with -i
● -v </host/path>:</container/path> : add volume mount into container; can be specified more than once
● -p <host-port>:<container-port> : publish a listening port to host system
● -e ENV_VAR_NAME=value : add environment variable in the container
● Complete list [Link]
docker exec command&param

Syntax
– docker exec <param>..<param> <container-name>
<commandline>

This command will execute <commandline> on
container <container-name>

Add `-i` and `-t` parameter to interact with the
execution
Docker compose manifest basics

Docker compose manifest consist of 1 file:
[Link] (or [Link] on
older version of docker-compose)

Consist of one mandatory section (services)
and some other sections (networks, volumes,
configs, secrets)
Services section

Key is service name

Each key contains several sub keys:
– container_name (set container name)
– image (container image to use)
– volumes (volume mounts, format is the same as -v)
– environments (environment variable, array with format
VARIABLE=value or set subkey VARIABLE with value)
– ports (expose port, format is same as -p)
– restart (restart policy, if host is restarted, should the container is
autostarted)

See more [Link]
vices/

You might also like