Gregology
Gregology

Reputation: 1725

Open port for docker container connected by VPN container

I want to run a docker container (kmb32123/youtube-dl-server) through a VPN in order to access geo blocked content. I found a suitable VPN docker image (ilteoood/docker-surfshark). I am trying to combine these two images in a single docker-compose.yml file. However, I'm unable to publish the ports for youtube-dl-server because of conflicting options.

conflicting options: port publishing and the container type network mode

Is there an alternative way to have youtube-dl-server route traffic though the docker-surfshark container while still exposing port 8080 locally so I can access it?

version: "2"

services: 
  surfshark-uk:
    image: ilteoood/docker-surfshark
    container_name: surfshark
    environment: 
        - SURFSHARK_USER=foo
        - SURFSHARK_PASSWORD=bar
        - SURFSHARK_COUNTRY=uk
        - CONNECTION_TYPE=udp
    cap_add: 
        - NET_ADMIN
    devices:
        - /dev/net/tun
    restart: unless-stopped
  youtube-dl-uk:
    image: "kmb32123/youtube-dl-server"
    container_name: yt-download-uk
    network_mode: container:surfshark-uk
    depends_on:
      - surfshark-uk
    ports:
      - 8080:8080
    volumes:
      - /Users/greg/Desktop/ukvids:/youtube-dl
    restart: unless-stopped
greg@computer docker $ docker-compose up
WARNING: Found orphan containers (surfshark, 949001ea6405_yt-download-uk) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
Creating surfshark-uk ... done
Creating yt-download-uk ... error

ERROR: for yt-download-uk  Cannot create container for service youtube-dl-uk: conflicting options: port publishing and the container type network mode

ERROR: for youtube-dl-uk  Cannot create container for service youtube-dl-uk: conflicting options: port publishing and the container type network mode
ERROR: Encountered errors while bringing up the project.

Upvotes: 4

Views: 3202

Answers (1)

Adiii
Adiii

Reputation: 59896

I think publishing port in surfshark-uk container will do the same job as youtube-dl-uk as its using network of surfshark-uk. so the port will be accessible on your host when try to hit

curl localhost:8080
yt-download-uk   | 172.26.0.1 - - [28/Jun/2020 02:03:17] "GET / HTTP/1.1" 404 720

So update docker-compose file and it should work.

  surfshark-uk:
    image: ilteoood/docker-surfshark
    container_name: surfshark
    ports:
      - 8080:8080

The port forwarding takes place with the VPN container, not the one that reuses its IP stack.

port publishing and the container type network mode

Upvotes: 2

Related Questions