Sobes.tech
Junior — Middle

How do Docker images and containers differ?

sobes.tech AI

Answer from AI

A Docker image is a template or 'snapshot' of a filesystem and configuration that contains everything needed to run an application: code, libraries, dependencies, and configurations.

A Docker container is a running instance of an image, an isolated environment where the application runs. The container uses the image as a base but can have its own state and processes.

Example:

# Create an image from a Dockerfile
docker build -t myapp:latest .

# Run a container from the image
docker run -d --name myapp_container myapp:latest

Thus, the image is a template, and the container is a working instance of that template.