Getting started. Some clarifications

I’m just getting started with Docker having heard great things.

I’ve worked through the first few tutorials but it looks like there are various ways of doing the same thing and i’m just getting more confused.

I hope someone can help clarify a couple of things?

  • Do I need a Dockerfile and compose file, or one or the other? How do they differ?

  • What is the recommended way to forward ports 80 and 443? HAproxy or Nginx on the host? HAproxy or nginx in a container? Any combination of these?

A Dockerfile specifies how to build a single Docker image; Docker Compose specifies how to run multiple containers in combination. I would say that learning how to write your own Dockerfile and use docker build is pretty essential; Compose is useful, but it’s also not the only way to run things, and it does have its limitations.

If your docker-compose.yml file has a block that says build: some_directory, then running docker-compose build will run some_directory/Dockerfile to build the image.