0 votes
1 view
in Devops and Agile by (28.1k points)

I have a Java socket application that requires a port number as a CLI argument. On my local machine, I can run it via:

docker run -d -p 1111:1111 --name <name> --link <link> <foo>/<bar> 1111

The problem is that I haven't found a solution to pass the port number when using Ansible (I have a different task that pulls the image). Current task:

- name: Run server

      docker:

          name: <name>

          image: <foo>/<bar>

          state: reloaded

          ports:

              - "1111:1111"

          links:

              - "<link>"

Is there a way to pass the port as a CLI argument? Or is there a simple way to work around this? I've thought about uploading a new image or using the command module but neither seems like the right way to go.

1 Answer

0 votes
by (48k points)

Ansible does not call the Docker CLI. It uses docker-py, so you cannot necessarily pass arbitrary command line arguments.

You are correct that this functionality does not exist in the ansible docker module currently, however, there is an open pull request to add this functionality:

To add this functionality

https://github.com/ansible/ansible/pull/7408

Or else you can simply pass arbitrary command lines arguments using the SHELL module.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...