Answers: <p>It is a quirk of the fact that macOS does not have native <code>docker</code>, and thus all(?) implementations have a backing virtual machine in which the Linux kernel and dockerd are running (something that I would have thought was obvious from the <code>docker-machine</code> you are currently aware of, but ... I guess not). It is almost certainly <em>that</em> machine which is listening on 22, given that most folks actually <em>do</em> want access to that virtual machine for troubleshooting</p>
  <p>I have better than average confidence that you can customize the virtual machine which <code>docker-machine</code> starts and ask it to bind ssh to :2222 (akin to <a href="https://github.com/docker/machine/pull/2648/files" rel="nofollow noreferrer">this</a>), or &quot;cheat&quot; and <code>docker-machine ssh systemctl stop sshd.service</code> type thing, freeing up the ssh port but from that point forward <code>docker-machine ssh</code> and maybe even <code>docker-machine stop</code> might not work as you expect</p>
  
Answers: CC BY-SA 4.0
Answers: 2021-06-19T04:07:30.573Z
Answers: 2021-06-19T04:07:30.573Z
Answers: mdaniel
Body: <p>I'm trying to a <code>gitlab/gitlab-ce</code> image up and running with docker-compose on macOS (Big Sur) (<code>docker-compose up -d</code>). I'm using <code>docker-machine</code> with the virtualBox driver.</p>
  <p>However, when starting the container I get the following error:</p>
  <pre><code>
  ERROR: for web  Cannot start service web: driver failed programming external connectivity on endpoint gitlab-docker_web_1 (236233cf090b94f98e2e82c2fa795bc7f6f5ff38e2ea14f3649e87313a21d196): Error starting userland proxy: listen tcp 0.0.0.0:22: bind: address already in use
  ERROR: Encountered errors while bringing up the project.
  </code></pre>
  <p>The issues is, I can't find anything running on port 22 on the host.</p>
  <pre><code>&gt; sudo lsof -i :22
  &gt;
  </code></pre>
  <p>returns nothing. Running <code>netstat -l | grep 22</code> to look for listening ports I don't see anything either:</p>
  <pre><code>tcp4       0      0  byrons-mac-pro.l.61179 229.26.211.130.b.https ESTABLISHED
  tcp4       0      0  byrons-mac-pro.l.60764 108.177.122.108.imaps  ESTABLISHED
  tcp4       0      0  byrons-mac-pro.l.60761 108.177.122.108.imaps  ESTABLISHED
  tcp4       0      0  byrons-mac-pro.l.60760 108.177.122.108.imaps  ESTABLISHED
  tcp4       0      0  byrons-mac-pro.l.60759 108.177.122.108.imaps  ESTABLISHED
  tcp4       0      0  byrons-mac-pro.l.60758 108.177.122.108.imaps  ESTABLISHED
  tcp4       0      0  byrons-mac-pro.l.60755 108.177.122.108.imaps  ESTABLISHED
  tcp4       0      0  byrons-mac-pro.l.60754 108.177.122.108.imaps  ESTABLISHED
  tcp4       0      0  byrons-mac-pro.l.54147 yi-in-f188.1e100.5228  ESTABLISHED
  tcp4       0      0  byrons-mac-pro.l.49743 104.22.52.136.https    ESTABLISHED
  tcp4       0      0  byrons-mac-pro.l.49734 yv-in-f188.1e100.5228  ESTABLISHED
  tcp4       0      0  byrons-mac-pro.l.49556 108.177.122.95.https   ESTABLISHED
  tcp4       0      0  byrons-mac-pro.l.49173 17.57.144.150.5223     ESTABLISHED
  tcp4       0      0  byrons-mac-pro.l.61183 52.96.122.50.https     TIME_WAIT
  tcp4       0      0  byrons-mac-pro.l.61182 52.96.122.50.https     TIME_WAIT
  udp4       0      0  byrons-mac-pro.l.56826 108.177.122.139.https
  c0fd8701c6b3232b stream      0      0                0 c0fd8701c6b32263                0                0
  c0fd8701c6b32263 stream      0      0                0 c0fd8701c6b3232b                0                0
  c0fd8701b7e36583 stream      0      0 c0fd8701b9bb407b                0                0                0 /var/folders/yt/c5z_l8554mq_fc3f0c5tpw600000gn/T/dotnet-diagnostic-2202-1621045110-socket
  c0fd8701add5cb63 stream      0      0                0 c0fd8701add5ca9b                0                0 /var/folders/yt/c5z_l8554mq_fc3f0c5tpw600000gn/T/vscode-ipc-a70bbba5-ec65-4f40-861a-0bc122628a75.sock
  c0fd8701a9b0232b dgram       0      0                0 c0fd8701a9b02263 c0fd8701a9b02263                0
  c0fd8701a9b02263 dgram       0      0                0 c0fd8701a9b0232b c0fd8701a9b0232b                0
  </code></pre>
  <p>I'm a bit stumped. Here's my <code>docker-compose.yml</code>:</p>
  <pre><code>web:
    image: &quot;gitlab/gitlab-ce:latest&quot;
    restart: always
    hostname: &quot;byrons-mac-pro.lan&quot;
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'http://byrons-mac-pro.lan'
        gitlab_rails['smtp_enable'] = true
        gitlab_rails['smtp_address'] = 'smtp.gmail.com'
        gitlab_rails['smtp_port'] = 587
        gitlab_rails['smtp_user_name'] = 'remove@cantellyou.com'
        gitlab_rails['smtp_password'] = '.........................'
        gitlab_rails['smtp_domain'] = 'smtp.gmail.com'
        gitlab_rails['smtp_authentication'] = 'login'
        gitlab_rails['smtp_enable_starttls_auto'] = true
        gitlab_rails['smtp_tls'] = false
        gitlab_rails['smtp_openssl_verify_mode'] = 'peer' # Can be: 'none', 'peer', 'client_once', 'fail_if_no_peer_cert', see http://api.rubyonrails.org/classes/ActionMailer/Base.html
        puma['worker_processes'] = 2
        sidekiq['max_concurrency'] = 10
        prometheus_monitoring['enable'] = false
    ports:
      - &quot;80:80&quot;
      - &quot;443:443&quot;
      - &quot;22:22&quot;
    volumes:
      - &quot;$GITLAB_HOME/config:/etc/gitlab&quot;
      - &quot;$GITLAB_HOME/logs:/var/log/gitlab&quot;
      - &quot;$GITLAB_HOME/data:/var/opt/gitlab&quot;
  </code></pre>
  
Tags: <docker><docker-compose><gitlab><macos><docker-machine>
Title: Docker compose up, Error starting userland proxy: listen tcp 0.0.0.0:22: bind: address already in use
UserDisplayName: Byron
ThreadText: # Docker compose up, Error starting userland proxy: listen tcp 0.0.0.0:22: bind: address already in use
  
  (Asked by: username_0 on 2021-05-15)
  
  I'm trying to a `gitlab/gitlab-ce` image up and running with docker-compose on macOS (Big Sur) (`docker-compose up -d`). I'm using `docker-machine` with the virtualBox driver.
  
  However, when starting the container I get the following error:
  
  ```
  
  ERROR: for web  Cannot start service web: driver failed programming external connectivity on endpoint gitlab-docker_web_1 (236233cf090b94f98e2e82c2fa795bc7f6f5ff38e2ea14f3649e87313a21d196): Error starting userland proxy: listen tcp 0.0.0.0:22: bind: address already in use
  ERROR: Encountered errors while bringing up the project.
  
  ```
  
  The issues is, I can't find anything running on port 22 on the host.
  
  ```
  > sudo lsof -i :22
  >
  
  ```
  
  returns nothing. Running `netstat -l | grep 22` to look for listening ports I don't see anything either:
  
  ```
  tcp4       0      0  byrons-mac-pro.l.61179 229.26.211.130.b.https ESTABLISHED
  tcp4       0      0  byrons-mac-pro.l.60764 108.177.122.108.imaps  ESTABLISHED
  tcp4       0      0  byrons-mac-pro.l.60761 108.177.122.108.imaps  ESTABLISHED
  tcp4       0      0  byrons-mac-pro.l.60760 108.177.122.108.imaps  ESTABLISHED
  tcp4       0      0  byrons-mac-pro.l.60759 108.177.122.108.imaps  ESTABLISHED
  tcp4       0      0  byrons-mac-pro.l.60758 108.177.122.108.imaps  ESTABLISHED
  tcp4       0      0  byrons-mac-pro.l.60755 108.177.122.108.imaps  ESTABLISHED
  tcp4       0      0  byrons-mac-pro.l.60754 108.177.122.108.imaps  ESTABLISHED
  tcp4       0      0  byrons-mac-pro.l.54147 yi-in-f188.1e100.5228  ESTABLISHED
  tcp4       0      0  byrons-mac-pro.l.49743 104.22.52.136.https    ESTABLISHED
  tcp4       0      0  byrons-mac-pro.l.49734 yv-in-f188.1e100.5228  ESTABLISHED
  tcp4       0      0  byrons-mac-pro.l.49556 108.177.122.95.https   ESTABLISHED
  tcp4       0      0  byrons-mac-pro.l.49173 17.57.144.150.5223     ESTABLISHED
  tcp4       0      0  byrons-mac-pro.l.61183 52.96.122.50.https     TIME_WAIT
  tcp4       0      0  byrons-mac-pro.l.61182 52.96.122.50.https     TIME_WAIT
  udp4       0      0  byrons-mac-pro.l.56826 108.177.122.139.https
  c0fd8701c6b3232b stream      0      0                0 c0fd8701c6b32263                0                0
  c0fd8701c6b32263 stream      0      0                0 c0fd8701c6b3232b                0                0
  c0fd8701b7e36583 stream      0      0 c0fd8701b9bb407b                0                0                0 /var/folders/yt/c5z_l8554mq_fc3f0c5tpw600000gn/T/dotnet-diagnostic-2202-1621045110-socket
  c0fd8701add5cb63 stream      0      0                0 c0fd8701add5ca9b                0                0 /var/folders/yt/c5z_l8554mq_fc3f0c5tpw600000gn/T/vscode-ipc-a70bbba5-ec65-4f40-861a-0bc122628a75.sock
  c0fd8701a9b0232b dgram       0      0                0 c0fd8701a9b02263 c0fd8701a9b02263                0
  c0fd8701a9b02263 dgram       0      0                0 c0fd8701a9b0232b c0fd8701a9b0232b                0
  
  ```
  
  I'm a bit stumped. Here's my `docker-compose.yml`:
  
  ```
  web:
    image: "gitlab/gitlab-ce:latest"
    restart: always
    hostname: "byrons-mac-pro.lan"
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'http://byrons-mac-pro.lan'
        gitlab_rails['smtp_enable'] = true
        gitlab_rails['smtp_address'] = 'smtp.gmail.com'
        gitlab_rails['smtp_port'] = 587
        gitlab_rails['smtp_user_name'] = 'remove@cantellyou.com'
        gitlab_rails['smtp_password'] = '.........................'
        gitlab_rails['smtp_domain'] = 'smtp.gmail.com'
        gitlab_rails['smtp_authentication'] = 'login'
        gitlab_rails['smtp_enable_starttls_auto'] = true
        gitlab_rails['smtp_tls'] = false
        gitlab_rails['smtp_openssl_verify_mode'] = 'peer' # Can be: 'none', 'peer', 'client_once', 'fail_if_no_peer_cert', see http://api.rubyonrails.org/classes/ActionMailer/Base.html
        puma['worker_processes'] = 2
        sidekiq['max_concurrency'] = 10
        prometheus_monitoring['enable'] = false
    ports:
      - "80:80"
      - "443:443"
      - "22:22"
    volumes:
      - "$GITLAB_HOME/config:/etc/gitlab"
      - "$GITLAB_HOME/logs:/var/log/gitlab"
      - "$GITLAB_HOME/data:/var/opt/gitlab"
  
  ```
  
  **Tags:** docker, docker-compose, gitlab, macos, docker-machine
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-06-19. Score: 1
  
  It is a quirk of the fact that macOS does not have native `docker`, and thus all(?) implementations have a backing virtual machine in which the Linux kernel and dockerd are running (something that I would have thought was obvious from the `docker-machine` you are currently aware of, but ... I guess not). It is almost certainly *that* machine which is listening on 22, given that most folks actually *do* want access to that virtual machine for troubleshooting
  
  I have better than average confidence that you can customize the virtual machine which `docker-machine` starts and ask it to bind ssh to :2222 (akin to [this](https://github.com/docker/machine/pull/2648/files)), or "cheat" and `docker-machine ssh systemctl stop sshd.service` type thing, freeing up the ssh port but from that point forward `docker-machine ssh` and maybe even `docker-machine stop` might not work as you expect
  
  
  ---
  
  