Allow for port forwarding when using docker executor. This is handy when needing to setup multiple docker containers that use the same port.
Most servers allow you to reset the listening port using a parameter switch, and you can pass a command
to your secondary containers already. What image/server are you wanting to run multiples of?
How can I use command
to do that?
Below is an example of what I wish to accomplish, granted I know there is no port
attribute.
All 3 apps run on port 80 which for the tests I want to forward to some other port.
docker:
- image: app1
name: app1
port: 80:8080
- image: app2
name: app2
port: 80:8081
- image: app3
name: app3
port: 80:8082
There is no (documented) port
key. You need a command
, as I said - see the reference here.
Your apps will also need to be able to accept a switch on the command line. For example, command: /path/to/app1 --port 8081
would launch this binary, and you’d have to modify the binary to accept the --port
switch. The server would then connect on localhost:8081
, and CircleCI would then work its automatic networking magic to make that available to the primary build container.
You cannot publish ports to the local environment though, as per your syntax 80:8081
. That requires Docker to be in privileged mode, and that would not be safe to run in a shared CI environment. Use the command approach instead.
Good luck!
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.