implement --publish in docker-compose run #916
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Documentation
docker-compose run options:
https://docs.docker.com/reference/cli/docker/compose/run/#options
Explanations
Using the below
docker-compose.yml
:The below
docker-compose run
command:publishes the port 12345 from the container to the host:
while the same using
podman-compose run
:does not publish the port:
The changes in this pull request aims to add the implementation of the
--publish
options inpodman-compose run
, which was completely forgotten.--publish
was added to the parser arguments:podman-compose/podman_compose.py
Lines 3002 to 3007 in 2681566
but then never used later (no occurences of
args.publish
).These changes allow the expected behavior:
$ podman ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 60e58363e0c0 docker.io/library/alpine:latest sh -c apk add --n... 1 second ago Up 1 second 0.0.0.0:12345->12345/tcp src_netcat-server_tmp20781
The new block
if args.publish:
is stategically put after the blockif not args.service_ports:
, which is emptyingcnt['ports']
when--service-ports
is not passed.Otherwise the ports added by
--publish
would be immediately emptied when--service-ports
is not passed, which is not what is expected :D.