wiremock / wiremock-docker

Wiremock Docker image
https://hub.docker.com/r/wiremock/wiremock
MIT License
211 stars 99 forks source link

EXPOSE cannot be overridden #53

Closed jon-frankel closed 1 year ago

jon-frankel commented 1 year ago

I am trying to set up both Wiremock and Traefik for local development, using docker-compose. I'm finding that Traefik will not start because port 8080 is already taken up by Wiremock. I've tried the following configuration for Wiremock, in an attempt to have it not use 8080 at all:

  wiremock:
    image: wiremock/wiremock
    expose:
      - 42020
    ports:
      - '42020: 42020'
    command: '--port 42020'
    volumes:
      - ./services/wiremock:/home/wiremock
CONTAINER ID   IMAGE                                      COMMAND                  CREATED          STATUS                  PORTS                                            NAMES
000012345678   wiremock/wiremock                          "/docker-entrypoint.…"   10 minutes ago   Up 10 minutes           8080/tcp, 8443/tcp, 0.0.0.0:42020->42020/tcp     directory-wiremock-1

Wiremock is in fact available at http://localhost:42020/__admin but when I try to start Traefik I get:

$ docker-compose up --build --detach traefik 
[+] Running 0/1
 ⠙ Container traefik  Starting
Error response from daemon: driver failed programming external connectivity on endpoint traefik (0d9edb76cc2294848c45bed94b0c1bb26082c48e1a5f155f901878e9c5dd065d): Bind for 0.0.0.0:80 failed: port is already allocated

I can try to change the port that Traefik listens as a workaround, but Wiremock is being the noisy neighbor here.

The Dockerfile has EXPOSE 8080 8443 hardcoded. I propose that this be mediated by build args.

jon-frankel commented 1 year ago

Apparently this was just a weird issue with Docker for Mac holding onto the port. I restarted and it seems fine now.