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

Local Environment Docker alternate port issue #4626

Closed
2 tasks
ntwb opened this issue Jan 22, 2018 · 6 comments
Closed
2 tasks

Local Environment Docker alternate port issue #4626

ntwb opened this issue Jan 22, 2018 · 6 comments
Labels
[Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.

Comments

@ntwb
Copy link
Member

ntwb commented Jan 22, 2018

Issue Overview

Unable to use an alternate port override in docker-compose.override.yml

These are the 4 configuration options I've tried thus far in my local docker-compose.override.yml file:

version: '3.1'

services:

  wordpress:
    image: wordpress
    ports:
      - 8484:80
version: '3.1'

services:

  wordpress:
    image: wordpress
    ports:
      - 8484
version: '3.1'

services:

  wordpress:
    ports:
      - 8484:80
version: '3.1'

services:

  wordpress:
    ports:
      - 8484

Steps to Reproduce (for bugs)

  1. Add a local docker-compose.override.yml file with one of the above configurations
  2. Run ./bin/setup-local-env.sh

Note: I have an existing source bound to port 8888 which is why I'm trying to use an alternate port.

Expected Behavior

I expected the Docker images to be successfully created and started

Current Behavior

The gutenberg_wordpress_1 container returns the error Error starting userland proxy: Bind for 0.0.0.0:8888 failed: port is already allocated

STATUS: Stopping Docker containers...
STATUS: Downloading Docker image updates...
Pulling wordpress_phpunit ... done
Pulling wordpress         ... done
Pulling cli               ... done
Pulling composer          ... done
Pulling mysql             ... done
STATUS: Starting Docker containers...
Creating network "gutenberg_default" with the default driver
Creating gutenberg_wordpress_phpunit_1 ... 
Creating gutenberg_wordpress_1         ... error
Creating gutenberg_mysql_1             ... 
Creating gutenberg_wordpress_1         ... 
Creating gutenberg_wordpress_phpunit_1 ... done

Creating gutenberg_cli_1               ... done
Creating gutenberg_composer_1          ... done
Creating gutenberg_mysql_1             ... done

ERROR: for wordpress  Cannot start service wordpress: driver failed programming external connectivity on endpoint gutenberg_wordpress_1 (ad43fb78be757d3bd6fa82bf46be75c39a21598697ba37e49ed61acc0f5931cc): Error starting userland proxy: Bind for 0.0.0.0:8888 failed: port is already allocated
ERROR: Encountered errors while bringing up the project.

Possible Solution

A workaround is to copy the base docker-compose.yml file to docker-compose.override.yml via cp docker-compose.yml docker-compose.override.yml and change the port from 8888 to 8484 and then change docker-compose up -d to docker-compose -f docker-compose.override.yml up -d in bin/install-docker.sh (src) and everything works as expected:

Welcome to...

,⁻⁻⁻.       .                 |
|  _. .   . |---  ,---. ,---. |---. ,---. ,---. ,---.
|   | |   | |     |---' |   | |   | |---' |     |   |
`---' `---' `---’ `---’ '   ` `---' `---’ `     `---|
                                                `---'
Run npm run dev, then open http://localhost:8484 to get started!

WordPress is now available at http://localhost:8484/ and works 👌

Screenshots / Video

Related Issues and/or PRs

Todos

  • Tests
  • Documentation

@pento any thoughts as to why none of my overrides posted above didn't work?

@pento
Copy link
Member

pento commented Jan 22, 2018

Well, that's annoying. I didn't realise docker-compose.override.yml added settings, instead of overriding them. (Ref: docker/compose#3729) Unfortunately, there doesn't seem to be any movement from Docker folk to change this behaviour.

The methods for working around this behaviour are all pretty hacky. The least awful option seems to be to use Variable Substitution in docker-compose.yml, but that's pretty ugly.

@ntwb
Copy link
Member Author

ntwb commented Jan 22, 2018

What about this with some docs to the effect of "If you need to override some thing, copy the entire
docker-compose.yml file to docker-compose.override.yml with your overrides inline" ?

diff --git bin/install-docker.sh bin/install-docker.sh
index a6617407..f4e0edd2 100755
--- bin/install-docker.sh
+++ bin/install-docker.sh
@@ -28,7 +28,12 @@ docker-compose pull --parallel
 
 # Launch the containers
 echo -e $(status_message "Starting Docker containers...")
-docker-compose up -d >/dev/null
+
+if [ -f ../docker-compose.override.yml ]; then
+    docker-compose -f docker-compose.override.yml up -d >/dev/null
+else
+    docker-compose up -d >/dev/null
+fi
 
 HOST_PORT=$(docker-compose port wordpress 80 | awk -F : '{printf $2}')

@pento
Copy link
Member

pento commented Jan 22, 2018

That will probably end up with people having out-of-sync docker-compose.override.yml files, which is less than ideal. 🙂

@ntwb
Copy link
Member Author

ntwb commented Jan 22, 2018

Cool, I'll take a look at a patch using said "Variable Substitution" a bit later...

@danielbachhuber danielbachhuber added the [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. label Jan 23, 2018
@danielbachhuber danielbachhuber added this to the WordPress 5.0 milestone Jun 4, 2018
@mtias mtias removed this from the WordPress 5.0 milestone Oct 12, 2018
@gziolo
Copy link
Member

gziolo commented Apr 23, 2019

@ntwb
Copy link
Member Author

ntwb commented Apr 24, 2019

Yes, that will work fine, closing this 👍

@ntwb ntwb closed this as completed Apr 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.
Projects
None yet
Development

No branches or pull requests

5 participants