Docker Community Forums

Share and learn in the Docker community.

Access Control with Ubuntu ufw on docker-compose

docker

(Brownie4597) #1

Hi All, i have a question.
This is my ufw configuration

상태: 활성
로깅: on (low)
기본 설정: deny (내부로 들어옴), allow (외부로 나감), deny (라우팅 된)
새 프로필: skip

This means incoming is deny all, outcoming is allow all ( ufw default setting )

Then, i have made a web service using docker-compose like this,

version: "3.4"
services:
  web:
    build: .
    image: test-web
    volumes:
      - /home/test/codes:/dev/web
    links:
      - redis
    ports:
      - 8080:8080

  redis:
    image: redis:4.0.9

In this situation, port 8080 is opened for all IPs. So i have changed like this,

version: "3.4"
services:
  web:
    build: .
    image: test-web
    volumes:
      - /home/test/codes:/dev/web
    links:
      - redis
    ports:
      - 127.0.0.1::8080

  redis:
    image: redis:4.0.9

But, i have to make this be opened specific IP for accessing these services.
How can i do this?


(Joffrey F) #2

Unless I misunderstand what you’re asking, you should be able to do this:

    ports:
      - 127.0.0.1:8080:8080