# Docker question about network

**URL:** <https://forums.docker.com/t/docker-question-about-network/127914>\
**Category:** General\
**Tags:** docker\
**Created:** [August 17, 2022, 10:47pm UTC](https://forums.docker.com/t/docker-question-about-network/127914 "2022-08-17T22:47:27Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![killmasta93](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/killmasta93/32/32959_2.png) [@killmasta93](https://forums.docker.com/u/killmasta93)\
**Post date:** [August 17, 2022, 10:47pm UTC](https://forums.docker.com/t/docker-question-about-network/127914/1 "2022-08-17T22:47:27Z")

</div>

Hi  
I was wondering if someone could shed on the issue im having, currently i have this docker-compose which im trying to give my container crowdsec an static IP but i keep getting an error

```auto
ERROR: for c0572b64cb76_swag user specified IP address is supported only when connecting to networks with user configured subnets

ERROR: for swag user specified IP address is supported only when connecting to networks with user configured subnets
ERROR: Encountered errors while bringing up the project

```

```auto
version: "2.1"
services:
  swag:
    build: .
    container_name: swag
    cap_add:
      - NET_ADMIN
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=America/Bogota
      - URL=domain.co
      - SUBDOMAINS=admin
      - VALIDATION=http
      - MAXMINDDB_LICENSE_KEY=Wdexxxx
      - DOCKER_MODS=linuxserver/mods:swag-maxmind|linuxserver/mods:swag-dashboard|linuxserver/mods:swag-crowdsec
      - CROWDSEC_API_KEY=70f1f70088xxxxxx
      - CROWDSEC_LAPI_URL=http://192.168.160.6:8080
      - ONLY_SUBDOMAINS=true
    networks:
      lsio:
        ipv4_address: 192.168.160.6
    volumes:
      - /swag:/config
    ports:
      - 443:443
      - 80:80
      - 81:81
    restart: unless-stopped

  crowdsec:
     container_name: crowdsec
     image: crowdsecurity/crowdsec:latest
     restart: unless-stopped
     depends_on:
       - swag
     networks:
       - lsio
     environment:
       - COLLECTIONS=crowdsecurity/nginx
       - GID=1000
     volumes:
       - /swag/log/nginx:/var/log/nginx
       - ./crowdsec/acquis.yaml:/etc/crowdsec/acquis.yaml
       - ./crowdsec/crowdsec-db:/var/lib/crowdsec/data/
       - ./crowdsec/crowdsec-config:/etc/crowdsec/
     security_opt:
      - no-new-privileges=true

networks:
  lsio:
   name: lsio
   driver: bridge
   ipam:
     driver: default
     config:
       - subnet: 192.168.160.0/24
         gateway: 192.168.160.254

```

---

<div class="post-metadata">

**Author:** ![rimelek](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/rimelek/32/41602_2.png) [@rimelek](https://forums.docker.com/u/rimelek)\
**Post date:** [August 18, 2022, 8:04pm UTC](https://forums.docker.com/t/docker-question-about-network/127914/2 "2022-08-18T20:04:26Z")

</div>

It should work. How do you run the containers and what is the version of your Docker Compose? Is it on Linux (I guess it is), Windows or Mac? Is it Docker Desktop (probably not)?

> [@killmasta93](#):
>
> `ERROR: for c0572b64cb76_swag `

It looks like you had two swag containers running. It happens sometimes when compose can’t properly start the containers and starts one with a prefix like above. I don’t exactly know why. I always just run `docker-compose down` and start the containers again.

---

<div class="post-metadata">

**Author:** ![killmasta93](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/killmasta93/32/32959_2.png) [@killmasta93](https://forums.docker.com/u/killmasta93)\
**Post date:** [August 18, 2022, 10:24pm UTC](https://forums.docker.com/t/docker-question-about-network/127914/3 "2022-08-18T22:24:11Z")

</div>

thank you so much for the reply,  
Correct i forgot to run docker-compose down  
i re ran it  
but still getting the issue

```auto
root@homelab:/swag# docker-compose up
Creating swag ... error

ERROR: for swag user specified IP address is supported only when connecting to networks with user configured subnets

ERROR: for swag user specified IP address is supported only when connecting to networks with user configured subnets
ERROR: Encountered errors while bringing up the project.

```

---

<div class="post-metadata">

**Author:** ![rimelek](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/rimelek/32/41602_2.png) [@rimelek](https://forums.docker.com/u/rimelek)\
**Post date:** [August 19, 2022, 1:06pm UTC](https://forums.docker.com/t/docker-question-about-network/127914/4 "2022-08-19T13:06:48Z")

</div>

Please, answer the rest of the questions too.

> [@rimelek](#):
>
> and what is the version of your Docker Compose? Is it on Linux (I guess it is), Windows or Mac? Is it Docker Desktop (probably not)?

---

<div class="post-metadata">

**Author:** ![killmasta93](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/killmasta93/32/32959_2.png) [@killmasta93](https://forums.docker.com/u/killmasta93)\
**Post date:** [August 19, 2022, 3:05pm UTC](https://forums.docker.com/t/docker-question-about-network/127914/5 "2022-08-19T15:05:16Z")

</div>

hi there sorry forgot that part im using ubuntu 20.04LTS

---

<div class="post-metadata">

**Author:** ![meyay](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/meyay/32/34000_2.png) [@meyay](https://forums.docker.com/u/meyay)\
**Post date:** [August 19, 2022, 5:27pm UTC](https://forums.docker.com/t/docker-question-about-network/127914/6 "2022-08-19T17:27:27Z")

</div>

> [@killmasta93](#):
>
> `subnet: 192.168.160.0/24`

Are you trying to use the same ip range your local lan has?

As @rimelek already pointed out, it should work like this for the swag service, if this indeed is a network private to the docker engine. If you answer aboves question with yes, then it would explain why it’s not working - then you might want to use the search term “macvlan” in the forum serach.

---

<div class="post-metadata">

**Author:** ![klausagnoletti](https://avatars.discourse-cdn.com/v4/letter/k/22d042/32.png) [@klausagnoletti](https://forums.docker.com/u/klausagnoletti)\
**Post date:** [August 21, 2022, 10:26am UTC](https://forums.docker.com/t/docker-question-about-network/127914/7 "2022-08-21T10:26:55Z")

</div>

Just wanted to give you a heads-up up that your question is being discussed in the CrowdSec Discord - join using [CrowdSec](https://discord.gg/crowdsec). The direct link is [Discord](https://discord.com/channels/921520481163673640/1009801503189520475)

---

<div class="post-metadata">

**Author:** ![killmasta93](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/killmasta93/32/32959_2.png) [@killmasta93](https://forums.docker.com/u/killmasta93)\
**Post date:** [August 21, 2022, 6:02pm UTC](https://forums.docker.com/t/docker-question-about-network/127914/8 "2022-08-21T18:02:48Z")

</div>

Thanks for the reply, currently my LAN ip is 192.168.7.0/24  
macvlan is when im trying to have the same LAN ip as the docker container?

---

<div class="post-metadata">

**Author:** ![killmasta93](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/killmasta93/32/32959_2.png) [@killmasta93](https://forums.docker.com/u/killmasta93)\
**Post date:** [August 21, 2022, 7:32pm UTC](https://forums.docker.com/t/docker-question-about-network/127914/9 "2022-08-21T19:32:38Z")

</div>

i was able to change instead of IP i put the name of the container of crowdsec not sure why i didnt think of that first

---

<div class="post-metadata">

**Author:** ![killmasta93](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/killmasta93/32/32959_2.png) [@killmasta93](https://forums.docker.com/u/killmasta93)\
**Post date:** [August 21, 2022, 7:33pm UTC](https://forums.docker.com/t/docker-question-about-network/127914/10 "2022-08-21T19:33:06Z")

</div>

thank you so much for asking on the discord channel but i realized that its better to put the name of the container instead of the IP

---

<div class="post-metadata">

**Author:** ![meyay](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/meyay/32/34000_2.png) [@meyay](https://forums.docker.com/u/meyay)\
**Post date:** [August 21, 2022, 7:36pm UTC](https://forums.docker.com/t/docker-question-about-network/127914/11 "2022-08-21T19:36:15Z")

</div>

… now imagine you would have shared in the first post WHY you want to give it a static ip… the whole thread would’ve been way shorter.

Note: If you try to access another container by it’s internal ip, then it’s high likely it is something not ment to be done like that. DNS-based service discovery is there for a reason…

---

<div class="post-metadata">

**Author:** ![killmasta93](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/killmasta93/32/32959_2.png) [@killmasta93](https://forums.docker.com/u/killmasta93)\
**Post date:** [August 21, 2022, 7:38pm UTC](https://forums.docker.com/t/docker-question-about-network/127914/12 "2022-08-21T19:38:01Z")

</div>

yeah sorry for that not being clear i completely forgot i could resolve by name my bad 🤐
