Back to Docker Course

Docker Course

What is a Docker Container?

A Docker container is a lightweight, portable, and self-sufficient unit that includes everything needed to run a piece of software, including the code, runtime, libraries, and configuration files.

  • Portability: The package is portable and can be easily shared and deployed on different environments without any changes.
  • Layered Architecture: Containers are built as layers of images stacked on top of each other.
  • Efficiency: The base OS image is typically very small (e.g., Alpine Linux).
  • Isolation: Containers provide isolation at the process level, ensuring that each container runs independently of others.

Managing Container

  • Starting a Container: docker run -d myapp (Run a container in detached mode)
  • Stopping a Container: docker stop <container_id> (Stop a running container)
  • Removing a Container: docker rm <container_id> (Remove a stopped container)

Docker Container Management

Docker Compose

  • Definition: Docker Compose is a tool for defining and running multi-container Docker applications. You use a docker-compose.yml file to configure your application's services.
  • Starting Services: docker-compose up (Start and run the services defined in the Compose file)
  • Scaling Services: docker-compose scale <service>=<number> (Scale the number of containers for a service)