Docker-compose error

Hi,

I’m trying to add Tyk to a docker-compose project. I copied the configuration over from the docker-compose.yml file provided in the tyk-gateway-docker repo. However, when I change the locations of the folders to mount as volumes, even though it creates the folders, I get the following error:

ERROR: for directlink-switchboard_tyk-gateway_1  Cannot start service tyk-gateway:
OCI runtime create failed: container_linux.go:380: starting container process caused: 
process_linux.go:545: container init caused: rootfs_linux.go:76: mounting "/host_mnt/Users/daniel/code/directlink-switchboard/domains/gateway/tyk.standalone.conf" to rootfs at "/opt/tyk-gateway/tyk.conf" caused: mount through procfd: not a directory: unknown:
Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

The folders are created when I run docker-compose up:
CleanShot 2021-09-29 at 11.31.01

Here is my docker-compose.yml:

version: '3.4'

services:
  eventstore:
    image: eventstore/eventstore:latest
    environment:
      - EVENTSTORE_CLUSTER_SIZE=${EVENTSTORE_CLUSTER_SIZE}
      - EVENTSTORE_RUN_PROJECTIONS=${EVENTSTORE_RUN_PROJECTIONS}
      - EVENTSTORE_START_STANDARD_PROJECTIONS=${EVENTSTORE_START_STANDARD_PROJECTIONS}
      - EVENTSTORE_EXT_TCP_PORT=${EVENTSTORE_EXT_TCP_PORT}
      - EVENTSTORE_HTTP_PORT=${EVENTSTORE_HTTP_PORT}
      - EVENTSTORE_INSECURE=${EVENTSTORE_INSECURE}
      - EVENTSTORE_ENABLE_EXTERNAL_TCP=${EVENTSTORE_ENABLE_EXTERNAL_TCP}
      - EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP=${EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP}
    networks:
      - eventstore_net
    ports:
      - '${EVENTSTORE_EXT_TCP_PORT}:${EVENTSTORE_EXT_TCP_PORT}'
      - '${EVENTSTORE_HTTP_PORT}:${EVENTSTORE_HTTP_PORT}'
    volumes:
      - type: volume
        source: eventstore-volume-data
        target: /var/lib/eventstore
      - type: volume
        source: eventstore-volume-logs
        target: /var/log/eventstore

  redis:
    image: redis:latest
    networks:
      - tyk_net

  tyk-gateway:
    image: docker.tyk.io/tyk-gateway/tyk-gateway:latest
    ports:
      - '${TYK_GW_PORT}:8080'
    networks:
      - tyk_net
    volumes:
      - ./domains/gateway/tyk.standalone.conf:/opt/tyk-gateway/tyk.conf
      - ./domains/gateway/apps:/opt/tyk-gateway/apps
      - ./domains/gateway/middleware:/opt/tyk-gateway/middleware
      - ./domains/gateway/certs:/opt/tyk-gateway/certs
    environment:
      - TYK_GW_SECRET=${TYK_GW_SECRET}
    depends_on:
      - redis

volumes:
  eventstore-volume-data:
  eventstore-volume-logs:

networks:
  eventstore_net:
  tyk_net:

Any help would be appreciated. Thanks!

Hey!

I took your docker-compose file and ran it without the eventstore bit and it worked for me.

Likely what you are doing is calling the docker-compose up command from a directory where the relative path “./domains/gateway/apps” is incorrect

Are you calling the command frm the directory where “domains” is located?

I am calling it from the project root so unfortunately the issue is not the relative path. Like I said, the folders are being generated properly. But it says it can’t find them after they’ve been created.

Very strange because I’m running what’s essentially the same docker-compose as the one you shared, but without the “/domains/gateway” path prefix.

Here’s what it looks like:

version: '3.4'

services:
  # eventstore:
  #   image: eventstore/eventstore:latest
  #   environment:
  #     - EVENTSTORE_CLUSTER_SIZE=${EVENTSTORE_CLUSTER_SIZE}
  #     - EVENTSTORE_RUN_PROJECTIONS=${EVENTSTORE_RUN_PROJECTIONS}
  #     - EVENTSTORE_START_STANDARD_PROJECTIONS=${EVENTSTORE_START_STANDARD_PROJECTIONS}
  #     - EVENTSTORE_EXT_TCP_PORT=${EVENTSTORE_EXT_TCP_PORT}
  #     - EVENTSTORE_HTTP_PORT=${EVENTSTORE_HTTP_PORT}
  #     - EVENTSTORE_INSECURE=${EVENTSTORE_INSECURE}
  #     - EVENTSTORE_ENABLE_EXTERNAL_TCP=${EVENTSTORE_ENABLE_EXTERNAL_TCP}
  #     - EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP=${EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP}
  #   networks:
  #     - eventstore_net
  #   ports:
  #     - '${EVENTSTORE_EXT_TCP_PORT}:${EVENTSTORE_EXT_TCP_PORT}'
  #     - '${EVENTSTORE_HTTP_PORT}:${EVENTSTORE_HTTP_PORT}'
  #   volumes:
  #     - type: volume
  #       source: eventstore-volume-data
  #       target: /var/lib/eventstore
  #     - type: volume
  #       source: eventstore-volume-logs
  #       target: /var/log/eventstore

  redis:
    image: redis:latest
    networks:
      - tyk_net

  tyk-gateway:
    image: docker.tyk.io/tyk-gateway/tyk-gateway:v3.2.1
    ports:
      - '8089:8080'
    networks:
      - tyk_net
    volumes:
      - ./tyk.standalone.conf:/opt/tyk-gateway/tyk.conf
      - ./apps:/opt/tyk-gateway/apps
      - ./middleware:/opt/tyk-gateway/middleware
      - ./certs:/opt/tyk-gateway/certs
    environment:
      - TYK_GW_SECRET=${TYK_GW_SECRET}
    depends_on:
      - redis

networks:
  tyk_net:

All I did was change the paths to apps, certs, tyk.conf, and middleware, and pinned the gateway version to v3.2.1

Does this help at all? Perhaps you can try pinning the v3.2.1 version?

I agree, it’s very odd, that’s why I’m here. Unfortunately I tried pinning v3.2.1 before posting here without success.

oh… I assumed the files existed beforehand, sorry misread that bit.

It’s possible the docker daemon created the tyk.standalone.conf as a directory instead of a file.

Can you check that?

edit: I was able to replicate this. You have to mount a file that exists, otherwise it creates it as a directory. Remove the line that mounts the tyk.conf please.