Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

305
Views
Getting Docker Container Id in Makefile to use in another command

I have a rule in my Makefile. Within this rule I need to manipulate some docker specific things so I need to get the id of the container in a portable way. In addition, I am using Docker Compose. Here is what I have that doesn't work.

a-rule: some deps
    $(shell uuid="$(docker-compose ps -q myService)" docker cp "$$uuid":/a/b/c .)

I receive no errors or output, but I do not get a successful execution.

My goal is to get the uuid of the container that myService is running in and then use that uuid to copy a file from the container to my docker host.

edit: the following works, but I'm still wondering if its possible to do inline variable settings

uuid=$(shell docker-compose ps -q myService)
a-rule: some deps
    docker cp "$(uuid)":/a/b/c .
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I ran into the same problem and realised that makefiles take output from shell variables with the use of $$. So I tried that and this should work for you:

a-rule: some deps
    uuid=$$(docker-compose ps -q myService);\ 
    docker cp "$$uuid":/a/b/c .

Bit late to the party but I hope this helps someone.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!