Home » What is a Docker container? How do you create, start and stop containers?

What is a Docker container? How do you create, start and stop containers?

Docker is a containerization technology that packages your application and all its dependencies together in the form of Containers to ensure that your application works seamlessly in any environment.

A container consists of an entire runtime environment: an application, plus all its dependencies, libraries and other binaries, and configuration files needed to run it, bundled into one package.

Containerizing the application platform and its dependencies eliminates any infrastructure differences and maintains consistency across environments.

They share the kernel with other containers, running as isolated processes in user space, on the host operating system.

Docker containers can be created by either creating a Docker image and then running it or you can use Docker images that are present on the Docker hub.

We can use Docker image to create Docker container by using the below command:

docker run -t -i <image name> <command name>

This command will create and start container.

Docker container can be run in two modes:

Attached:  Where it will be run in the foreground of the system you are running, provides a terminal inside to container when -t option is used with it, where every log will be redirected to stdout screen.

Detached: This mode is usually run in production, where the container is detached as a background process and every output inside the container will be redirected to log files which can be viewed by docker logs command.

To check the list of all running containers with status on a host:

docker ps -a

To stop the Docker container:

docker stop <container ID>

To restart the Docker container you can use:

docker restart <container ID>

What is Automation?