docker-compose: the version does matter

docker-compose-2023-07-06-01-04-58.png

I know, serious people use Kubernetes, but all I had was three small containers to deploy to run my website, all on the same host, and hence I figured docker-compose would do. So I set it all up, created my docker-compose.yml YAML file, tried to deploy it - only to discover that on the deployment host some of the tags would not work, one of them being target.

So I spent the next few hours digging into it and, it turns out, some version of docker-compose read in all the tags they can interpret, while others only interpret the ones allowed in the version specified in the first line of the file:

version: "3.7"

services:

  web:
    build:
      context: .
      target: "web"
    container_name: "web0"

  wproxy:
    build:
      context: .
      target: "wproxy"
    container_name: "wproxy0"
    ports:
      - "80:80"
    volumes:
      - letsencrypt_data:/etc/letsencrypt
    links:
      - web

  wproxy_s:
    build:
      context: .
      target: "wproxy_s"
    container_name: "wproxy_s0"
    ports:
      - "443:443"
    volumes:
      - letsencrypt_data:/etc/letsencrypt
      - html_home:/var/www/html
    links:
      - web

volumes:
  letsencrypt_data:
  html_home:

Initially my file read:

version: "3"

When I changed to to its current form:

version: "3.7"

The issue went away.

So yes, docker-compose is a useful orchestration tool, allowing to consistently and easily deploy small containerized applications. Only remember: version does matter, make sure you specify the correct one.

Links

link_tree_20230629.png



0
0
0.000
11 comments
avatar

pixresteemer_incognito_angel_mini.png
Bang, I did it again... I just rehived your post!
Week 163 of my contest just started...you can now check the winners of the previous week!
!PIZZA
6

0
0
0.000
avatar

Great work bro. I will definitely visit your website.

0
0
0.000
avatar

Small workplace story here... I think it's relatable :^)

So, we also use Docker at work. After all, who doesn't like the idea of deploying containers? That being said, no one here really bothers about the version. Probably it's out of pure fear on breaking things when upgrading, or no one just has the time for that... anyway, some of our stuff are old. That includes Docker.

And how old are we talking about... let's just say that when we try to finally use Docker Compose to deploy one of the new fancy ideas we had, all the commands online didn't worked. The Docker we had simply refused to recognize it as an extension despite we threw it into the correct directory. We had to add docker-compose the binary to PATH, then run docker-compose instead of docker compose.

It still functions, I don't know how (perhaps by pure luck...), but yeah, versions do matter. Compatibility only works till an extent.

0
0
0.000