Files
containers/slides/custom/Exercise_Dockerfile.md
Marco Verleun b6e70b4cac
Some checks failed
Gitea Actions Demo Training / Explore-Gitea-Actions (push) Failing after 14s
Fixed files
2024-01-07 21:17:15 +01:00

794 B

Exercise — writing Dockerfiles

  1. Check out the code repository:

    git clone https://git.verleun.org/training/docker-build-exercise.git
    
  2. Add a Dockerfile that will build the image:

    • Use python:3.9.9-slim-bullseye as the base image (FROM line)

    • Expose port 8000 (EXPOSE)

    • Installs files in '/usr/local/app' (WORKDIR )

    • Execute the command uvicorn app:api --host 0.0.0.0 --port 8000

  3. Build the image with docker build -t exercise:1 .

  4. Run the image: docker run -d -p 8123:8000 exercise:1


Again, with docker-compose (optional)

Create a docker-compose.yml with the following content:

version: "3"
services:
  app:
    build: .
    ports:
    - 8123:8000

Start the container: docker-compose up -d