Week 7 Lecture
Week 7 Lecture
Discussion:
Understanding Dockerfile
Create a Dockerfile:
# Expose port 80
EXPOSE 80
Build and run the custom image:
docker ps
Docker Compose allows you to define and run multiple containers using a single
configuration file (docker-compose.yml).
version: '3'
services:
web:
image: nginx
ports:
- "8080:80"
volumes:
- ./html:/usr/share/nginx/html
db:
image: mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: rootpass
MYSQL_DATABASE: mydb
docker-compose up -d
docker-compose ps
Stop the application:
docker-compose down
Containers in the same Docker network can communicate using service names.
Useful for microservices architecture.
5. Lab Activity:
Build a custom Docker image for a basic web app.
Use Docker Compose to set up a multi-container environment with: