Home > Software engineering >  Dockerfile its not copying all files
Dockerfile its not copying all files

Time:08-30

I'm trying to run a discord.py bot on a docker container. But when I'm running the container, docker says that I'm "missing a module". The Dockerfile its not copying all the files/folders from the source code.

This is my directory:

enter image description here

These are the contents of my docker-compose.yml:

version: '3'

services:
  bot:
    build: .
    restart: always
    volumes:
      - ./.env:/usr/src/app/.env

This is my Dockerfile:

FROM python:bullseye

WORKDIR /usr/app/src

COPY bot bot

CMD ["python", "-m", "bot"]

When I run # sudo docker compose up It fails with the following log: enter image description here

Checking the docker image files, it seems like its copying all the contents inside of the bot folder, but its not copying the folder itself.

enter image description here

The code works fine if I run it outside of the container, so is not related to this discord bot code.

How can I fix this? This is my first docker container I'm new really with this.

CodePudding user response:

The correct syntax should be:

COPY bot bot/

By design, COPY always copies the contents of the directory if the source is a directory, and by adding the trailing / to the destination you tell docker that the destination is a directory, so it will create it for you if needed.

See the full documentation.

  • Related