Docker Compose v2 and Profiles Are the Best Thing Ever

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ก.ค. 2024
  • Containers start / stop faster and profiles let you start specific services in different environments.
    Hit the subscribe button to receive more videos like this!
    REFERENCE LINKS
    ---------------------------------------------------
    ► www.docker.com/blog/announcin...
    ► github.com/nickjj/docker-flas...
    ► github.com/nickjj/ansible-docker
    ► nickjanetakis.com/blog/docker...
    COURSES
    ---------------------------------------------------
    Courses I've created that focus on web dev and deployment topics.
    ► nickjanetakis.com/courses/
    THE TOOLS I USE / GEAR
    ---------------------------------------------------
    ► nickjanetakis.com/blog/the-to...
    FOLLOW ME ELSEWHERE
    ---------------------------------------------------
    ► Twitter: / nickjanetakis
    ► GitHub: github.com/nickjj
    TIMESTAMPS
    ---------------------------------------------------
    0:00 -- Intro
    0:29 -- Docker's timeline for Docker Compose v2
    2:46 -- Going over the example Flask app
    3:46 -- The difference between how v1 and v2 runs
    4:32 -- Checking out how Docker Compose profiles work
    7:03 -- The profile flag vs using the COMPOSE_PROFILES env variable
    8:03 -- v2 starts and stops containers a bit faster than v1
    9:39 -- The env var approach makes it easy to control which services to run
    13:28 -- The profile command line flag applies to all compose commands
    14:21 -- You can easily split up your services onto multiple servers

ความคิดเห็น • 13

  • @sanlobach789
    @sanlobach789 11 หลายเดือนก่อน +1

    Nice! I was trying to find a way to compose up only 3 of 5 containers in my dev environment using V1, but luckely I've found this solution with profiles in V2)) Thanks

  • @danleyb23
    @danleyb23 ปีที่แล้ว

    How can one ignore the profiles then run a compose command on all services?

    • @NickJanetakis
      @NickJanetakis  ปีที่แล้ว

      If you don't put a service into a profile it'll always run, if you want to run all services while using profiles you'll need to supply all of the profiles.

  • @danleyb23
    @danleyb23 ปีที่แล้ว +1

    specifying multiple profiles as part of the `docker compose up --profiles` doesn't seem to work.

    • @NickJanetakis
      @NickJanetakis  ปีที่แล้ว +1

      It works, it's listed here docs.docker.com/compose/profiles/#enable-multiple-profiles, you can supply --profile web --profile worker up.

    • @mightycoderx
      @mightycoderx 5 หลายเดือนก่อน +1

      ​​​@@NickJanetakis No no, but he's actually right --profile is a flag of docker cli's subcommand "compose" so it goes before compose's subcommands
      `docker compose [compose flags] [subcommand's flag]`
      Ex.
      `docker compose --profile PROFILE_NAME up -d`

    • @NickJanetakis
      @NickJanetakis  5 หลายเดือนก่อน +1

      @@mightycoderx Yep, I covered that on video at 13:28, the timestamp note also mentions "The profile command line flag applies to all compose commands".

    • @mightycoderx
      @mightycoderx 5 หลายเดือนก่อน +2

      @@NickJanetakis still didn't watch the video, I just answered based on what you wrote here, I wanted them to understand it in a more dynamic way, to understand it like I do, I'ma watch the video now!

  • @akshayc4145
    @akshayc4145 ปีที่แล้ว +2

    Great

    • @NickJanetakis
      @NickJanetakis  ปีที่แล้ว +1

      Thanks!

    • @akshayc4145
      @akshayc4145 ปีที่แล้ว

      @@NickJanetakis Just a doubt, earlier we specify docker compose syntax versions on the start of a compose file, but after version 3.8 there is no version update but says based on "compose specifications", does that mean we now don't need to write the version anymore and new compose just combines the syntax of v2 and v3..is it like that

    • @NickJanetakis
      @NickJanetakis  ปีที่แล้ว +1

      @@akshayc4145 Yes it combines them. The specification states:
      "The Compose spec merges the legacy 2.x and 3.x versions, aggregating properties across these formats and is implemented by Compose 1.27.0+."
      That's near the top of: docs.docker.com/compose/compose-file/