📡 You're offline — showing cached content
New version available!
Quick Access
SQL Intermediate

Docker for Developers: Containers, Images and Compose

Learn Docker from scratch — writing Dockerfiles, docker-compose for multi-service apps, volumes, networking, and essential commands.

EzyCoders Admin December 17, 2025 11 min read 1 views
Docker for Developers Containers Images Compose
Share: Twitter LinkedIn WhatsApp

Docker for Developers

Docker packages applications with all dependencies into containers — eliminating "works on my machine" problems. Every modern development workflow uses Docker.

FROM php:8.3-fpm-alpine
RUN apk add --no-cache nginx git
RUN docker-php-ext-install pdo pdo_mysql opcache
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
WORKDIR /var/www/html
COPY composer.json composer.lock ./
RUN composer install --no-dev --optimize-autoloader
COPY . .
RUN chown -R www-data:www-data storage
EXPOSE 9000
CMD ["php-fpm"]

docker-compose.yml

version: '3.9'
services:
  app:
    build: .
    volumes:
      - .:/var/www/html
    environment:
      DB_HOST: mysql
    depends_on:
      - mysql

  mysql:
    image: mysql:8.0
    environment:
      MYSQL_DATABASE:      ezycoders
      MYSQL_ROOT_PASSWORD: secret
    volumes:
      - mysql_data:/var/lib/mysql

  redis:
    image: redis:7-alpine

volumes:
  mysql_data:
docker build -t myapp:1.0 .
docker run -p 8080:80 myapp:1.0
docker ps                              # running containers
docker exec -it container_name bash   # shell into container

docker-compose up -d                  # start all services
docker-compose logs -f app            # follow logs
docker-compose exec app php artisan migrate

Q: Image vs Container?

An image is the read-only template/blueprint. A container is a running instance of an image. One image spawns many containers. Images are built and stored in registries; containers are ephemeral — changes inside are lost unless volumes are used.

EzyCoders Admin
Written by
EzyCoders Admin

Team Lead and Full-Stack Developer with experience in PHP, JavaScript, SQL, DSA, and System Design. Passionate about software engineering, scalable web technologies, and helping developers prepare for coding interviews and tech careers through practical tutorials and professional guidance.

Comments (0)

No comments yet. Be the first!

Leave a Comment