Hi team, 1. suppose we have docker image A on regi...
# general
w
Hi team, 1. suppose we have docker image A on registry B, how can we run the image A using pants 2. suppose we have docker image A on registry B, how can we build another image C on top of image A and then run it 3. is there any support for running
docker-compose up
using pants?
👋 2
h
@curved-television-6568 is the best person to answer this!
c
Hi, so there’s no direct way to do 1, without it being a no-op version of 2 so I’ll skip straight to that one, but will first say that for 3 there is no support currently in pants for using
docker-compose
. So, to build an image and run it:
Copy code
# some/BUILD
docker_image(name="C")
Copy code
# some/Dockerfile
FROM B/A:latest
RUN echo Hello > msg.txt
COMMAND ["cat", "msg.txt"]
Copy code
$ pants run some:C
# or, referencing the Dockerfile works too
$ pants run some/Dockerfile
More comprehensive examples in the docs https://www.pantsbuild.org/docs/tagging-docker-images and follow up questions here always welcome as well.
h
@witty-laptop-37343 to clarify question 1: Image A is not built by Pants, it already exists in the registry?
w
yep, it already exists in the registry
h
Gotcha. Right now Pants can run images that it builds, so you can test them out, but not arbitrary images. They don't have an "address" in a BUILD file today. Although I suppose they could. But at that point why not just use
docker run
directly?
w
currently in our Jenkins pipeline agent doesn’t have docker, I assume that pants’ virtual environment will setup docker internally?
c
sorry no, you need docker setup already.
👀 1