Nick
Nick

Reputation: 175

If I run `docker-compose up` do I need a Dockerfile in the directory as well as a docker-compose.yml file?

Do I absolutely need to have a Dockerfile in my directory when using the command docker-compose up? I don't believe a Dockerfile is necessary but want to be sure.

If I only have a docker-compose.yml file using pre-built images, there would be no need for a Dockerfile.

Correct me please! Thanks in advance.

Upvotes: 15

Views: 6931

Answers (1)

Efrat Levitan
Efrat Levitan

Reputation: 5622

docker-compose lets you choose between the 2 options

  • build the container from a specified image:

    services:
      example:
        image: your/imagename
    
  • build the container out of a Dockerfile:

    services:
      example:
        build: 
          context: path/to/Dockerfile/dir
          dockerfile: Dockerfile #here you specify the name of your Dockerfile file
    

Upvotes: 19

Related Questions