Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS : cannot listen on the TCP port: listen tcp4 :53: bind: address already in us #17690

Closed
Constantin1489 opened this issue Mar 3, 2023 · 4 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. machine macos MacOS (OSX) related

Comments

@Constantin1489
Copy link

Constantin1489 commented Mar 3, 2023

Issue Description

I ran the code below. ( I did podman machine set --rootful)

$ podman volume create pihole_pihole
$ podman volume create pihole_dnsmasq
$ podman run -d --name pihole7 \
    -e WEBPASSWORD="11111" \
    -e DNS1=8.8.8.8 \
    -e DNS2=1.1.1.1 \
    -v pihole_pihole:/etc/pihole:Z \
    -v pihole_dnsmasq:/etc/dnsmasq.d:Z \
    -p 8889:80 \
    -p 53:53/tcp \
    -p 53:53/udp \
    -p 443:443 pihole/pihole:latest

Output :

Error: unable to start container "13f722fc3600bcf6ac50c595dc214fa74e0804b56efe69dcafb7bec67b528f61": cannot listen on the TCP port: listen tcp4 :53: bind: address already in use

$ sudo lsof -i:53

There is no output.

$ podman machine info

Output :

Host:
  Arch: amd64
  CurrentMachine: ""
  DefaultMachine: ""
  EventsDir: /var/folders/_r/c7ygdkk13254ngxz6j7c6y3m0000gn/T/podman-run--1/podman
  MachineConfigDir: /Users/username/.config/containers/podman/machine/qemu
  MachineImageDir: /Users/username/.local/share/containers/podman/machine/qemu
  MachineState: ""
  NumberOfMachines: 1
  OS: darwin
  VMType: qemu
Version:
  APIVersion: 4.4.2
  Built: 1677167961
  BuiltTime: Fri Feb 24 00:59:21 2023
  GitCommit: 74afe26887f814d1c39925a1624851ef3590e79c
  GoVersion: go1.20.1
  Os: darwin
  OsArch: darwin/amd64

$ system_profiler SPSoftwareDataType

Software:

    System Software Overview:

      System Version: macOS 13.2.1 (22D68)
      Kernel Version: Darwin 22.3.0
      Boot Volume: Macintosh HD
      Boot Mode: Normal
      Computer Name:  username
      User Name: username
      Secure Virtual Memory: Enabled
      System Integrity Protection: Enabled
      Time since boot: 1 hour, 49 minutes

Steps to reproduce the issue

Steps to reproduce the issue

  1. I believe the code I wrote will reproduce the issue.

Describe the results you received

If it's not podman's bug, then it is a macOS config problem.

Describe the results you expected

The docker image worked great in docker. So I want to know whether I didn't configure ports or it's just a bug.

podman info output

Host:
  Arch: amd64
  CurrentMachine: ""
  DefaultMachine: ""
  EventsDir: /var/folders/_r/c7ygdkk13254ngxz6j7c6y3m0000gn/T/podman-run--1/podman
  MachineConfigDir: /Users/username/.config/containers/podman/machine/qemu
  MachineImageDir: /Users/username/.local/share/containers/podman/machine/qemu
  MachineState: ""
  NumberOfMachines: 1
  OS: darwin
  VMType: qemu
Version:
  APIVersion: 4.4.2
  Built: 1677167961
  BuiltTime: Fri Feb 24 00:59:21 2023
  GitCommit: 74afe26887f814d1c39925a1624851ef3590e79c
  GoVersion: go1.20.1
  Os: darwin
  OsArch: darwin/amd64

Podman in a container

No

Privileged Or Rootless

Privileged

Upstream Latest Release

Yes

Additional environment details

I ran podman on local machine.

Additional information

Additional information like issue happens only occasionally or issue happens with a particular architecture or on a particular setting

@Constantin1489 Constantin1489 added the kind/bug Categorizes issue or PR as related to a bug. label Mar 3, 2023
@github-actions github-actions bot added the macos MacOS (OSX) related label Mar 3, 2023
@baude
Copy link
Member

baude commented Mar 4, 2023

was the lsof run in macos or inside the vm ?

@Constantin1489
Copy link
Author

Constantin1489 commented Mar 4, 2023

@baude, Thank you for helping me.

I ran lsof command in macOS. Because of the problem, the container created but couldn't run on podman.

When I tried with different container settings, which changed ports, I realized there was no lsof in the container.
Pihole is a DNS server. therefore without using 53, 443 port, I won't work as a DNS server.

the different setting

sudo podman run --rm --name pihole \
    -e WEBPASSWORD="11111" \
    -e DNS1=8.8.8.8 \
    -e DNS2=1.1.1.1 \
    -v pihole_pihole:/etc/pihole:Z \
    -v pihole_dnsmasq:/etc/dnsmasq.d:Z \
    -p 8889:80 \
    -p 8890:53/tcp \
    -p 8890:53/udp \
    -p 8891:443 pihole/pihole:latest

I also tried this command.

sudo podman run -dt --pod new:pihole --name pihole8 \
    -e WEBPASSWORD="111111" \
    -e DNS2=1.1.1.1 \
    -e DNS1=8.8.8.8 \
    -v pihole_pihole:/etc/pihole:Z \
    -v pihole_dnsmasq:/etc/dnsmasq.d:Z \
    -p 8889:80 \
    -p 53:53/tcp \
    -p 53:53/udp \
    -p 443:443 pihole/pihole:latest

Output

Error: starting some containers: internal libpod error
$ podman pod list
POD ID        NAME        STATUS      CREATED      INFRA ID      # OF CONTAINERS
8e43f8f22682  pihole      Created     7 hours ago  fa9a04841cfb  2

I also tried this command to just make it run.

sudo podman run -dt --pod new:pihole --name pihole8 \
    -e WEBPASSWORD="111111" \
    -e DNS2=1.1.1.1 \
    -e DNS1=8.8.8.8 \
    -v pihole_pihole:/etc/pihole:Z \
    -v pihole_dnsmasq:/etc/dnsmasq.d:Z \
    -p 8889:80 \
    -p 8890:53/tcp \
    -p 8890:53/udp \
    -p 8891:443 pihole/pihole:latest

Output

$ podman pod list            
POD ID        NAME        STATUS      CREATED      INFRA ID      # OF CONTAINERS
14764aad0828  pihole      Running     7 hours ago  eb1231ed2e41  2

This one just works but not as a DNS server, Because of the improper ports.

@Luap99
Copy link
Member

Luap99 commented Mar 6, 2023

Note you need to check in the VM not the container. (podman machine ssh ss -tulpn)
I am pretty sure the problem is that inside the VM there is systemd-resolved running on 127.0.0.54:53.
I doubt that we get any benefit from running using systemd-resolved so I suggest that we disable it in the machine VM via ignition.

@Luap99 Luap99 added the machine label Mar 6, 2023
@Constantin1489
Copy link
Author

Thank you for giving me perfect answer! I appreciate it! Also you fix my understanding to vm and container!

podman machine ssh sudo sed -r -i.orig 's/#?DNSStubListener=yes/DNSStubListener=no/g' /etc/systemd/resolved.conf
podman machine ssh systemctl restart systemd-resolved

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Aug 30, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. machine macos MacOS (OSX) related
Projects
None yet
Development

No branches or pull requests

3 participants