Docker Commands

Docker is an open source project that was released by dotCloud in 2013. Docker is build on features of Linux Container (LXC) technology, and just like any container technology it has its own file system, storage, CPU, RAM memory, etc.

But hey, what is a container? From the very basic point of view, a container encapsulates all the software dependencies associated with a running application. There are two core concepts of the containers:

  1. Package together application and all its dependencies as a single deployable unit. This results in faster innovation and quicker deployment cycles. It also reduces regression risk due to the OS upgrades;
  2. Decouples the application from the operating system, which allows containers to be portable for resiliency and scalability.

Docker Components:

  • Image
  • Container (a container is the standard unit in which the application service resides or is transported).
  • Docker hub/registry
  • Docker engine
  • Docket file

To start working with docker first thing you should do is to install docker engine (known also as docker hub). If you are running MAC OS you should install it from here. Now that you have docker installed, let’s see some docker command in action.

Check your docker version

docker –version
docker version

Check how many containers are running

docker ps

You can use docker ps -a and it will show you all the container (indiferent daca sunt oprite, started sau in orice alta status).

This command will show you a list of all the running processes.

Get statistics about the running containers

docker stats

Get the list of all the available images

docker images

This command shows a list of the docker images cached locally (aka, images available in your local box). An image is specified by the repository name and tag (repository:tag).

Search for images

docker search <key-word>

Build a docker image from a DockerFile

docker build

Run a docker container in the background

docker run -d <container-name>

The docker run command will create the container using the specified image. The -d flag is used to run the container in the background.

Other flag available:

-i starts an interactive container. When finish you can type exit, to exit the container (docker also will shout down the container).
-t creates a pseudo-TTY that attaches stdin and stdout

 

Remove a container

You can always remove a container if you know its id

docker rm <container-id>

Open an interactive bash shell inside the one of the running containers

docker <container-name> /bin/bash

 

docker exec <container-name>

 

Stop a container

docker stop <container-id>

And if you can’t remember any of the above commands you can type

docker –help

docker –help | grep -i image

 

Other alternatives to Docker:

  • rocket containers
  • garden cloud foundry
  • open container initiative

Useful Resources:

An introduction to containers

https://www.onlinedigitallearning.com/mod/book/view.php?id=16800&chapterid=132

Spread the love
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Leave a Reply