8000 Updated the command to run the Docker image by javiereguiluz · Pull Request #10490 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

Updated the command to run the Docker image #10490

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

Closed
wants to merge 3 commits into from

Conversation

javiereguiluz
Copy link
Member

We merged #10131 but the command shown to serve the image locally doesn't work for me. I'm using Docker 18.06.0-ce. The change I made in this PR worked for me ... but we'd need the help of Docker experts to verify and discuss about the best possible command that will work under any circumstances. Thanks!

@ghost
Copy link
ghost commented Oct 15, 2018

I am not sure if you want to run this detached -d?

@javiereguiluz
Copy link
Member Author
javiereguiluz commented Oct 15, 2018

I don't even know what -d means. I just Googled for this because the previous command didn't work for me. The new command worked for me. But I don't understand anything.

That's why we need a Docker expert to show their experience and tell us: "you must run this other command instead. It's the right one and it will always run correctly." Thanks!

@andrewmy
Copy link

--rm removes the container after use, I think it's a needed option.
The real fix would be putting a space between -p and 80:80 in the original instruction, I guess. Have to check though.

@dkarlovi
Copy link
Contributor
dkarlovi commented Oct 15, 2018
docker run -d -p 80:80 --name symfony-docs symfony-docs

should be correct.

Note, you can have collisions on both name and port (if they're taken in host's scope). I'd recommend using some other port on host since you don't care either way.

$ docker run --name test-nginx -d -p 1337:80 nginx:alpine
# now available at http://127.0.0.1:1337/
$ docker stop test-nginx
# no longer available, container stopped
$ docker start test-nginx
# available again
$ docker stop test-nginx
$ docker rm test-nginx
# container removed, image stays
$ docker rmi nginx:alpine
# image no longer available

@dkarlovi
Copy link
Contributor

BTW if the image is only meant as a build utility, you can probably provide it from Docker Hub instead of having the user build their own, that way they just start your image on their machine and start working on the docs.

@javiereguiluz
Copy link
Member Author

@dkarlovi I've just run your command and it didn't work for me :(

docker: Error response from daemon: Conflict. The container name "/symfony-docs" 
is already in use by container 
"66a9fed92612387aa9c55e3da130966db91dbbc5024d07c5ac340ae9c21d095f". You have to 
remove (or rename) that container to be able to reuse that name.

@javiereguiluz
Copy link
Member Author

And the original command failed because of this error:

docker: Error response from daemon: driver failed programming external connectivity on endpoint distracted_curran 
(75420f310b5a1d112b9d0a7c2ac297c57b6676dcad4f1902d3d2bad48d06b43c): Error starting 
userland proxy: listen tcp 0.0.0.0:80: bind: address already in use.

@andrewmy
Copy link
andrewmy commented Oct 15, 2018

You already got the container running, and thus can't use the same name and port. --rm option would remove it after exiting.
For now, you can do docker stop symfony-docs

So it looks like:

  • the instruction also needs a note about choosing the port because 80 might be already taken;
  • --rm option is useful for this kind of temporary work;
  • -d (detached) option is not useful because then you need a separate command to stop it.

The best approach would be creating an image on Docker hub which you could just pull and run.
The quickest solution would be:

  • add a note about the desired port;
  • docker run --rm -p <YOUR_PORT>:80 symfony-docs

@javiereguiluz
Copy link
Member Author

Thank you all for your help! I appreciate a lot the explanations. Thanks!

I've tested everything and it seems that the original command worked ... except that I needed to add the white space as @andrewmy suggested.

@dkarlovi
Copy link
Contributor

@javiereguiluz consider getting hold of this account: https://hub.docker.com/r/symfony/

This would allow you to do

# note: Docker Hub allows for this to be fully automated and the images kept up to date
docker build . -t symfony/symfony-docs
docker push symfony/symfony-docs

Now your instructions can be:

docker run --rm --detach -p 1337:80 symfony/symfony-docs

I'd even go a step further and do what I usually do: add a Makefile in project root to allow you to:

# this one does all the required steps
make docs-server-start 

# do work on the docs, not worrying about the infra required

# shut down & remove the server when done since it's not needed anymore
make docs-server-stop

@javiereguiluz
Copy link
Member Author

@dkarlovi we're going to try to recover the symfony Docker ID. Thanks for the heads up. Regarding the other comments, I agree ... but we're in the middle of an internal project to change some important things about Symfony Docs. I don't know if we'll make it, but if we do, we'll revisit this idea to make local builds much easier. Thanks!

javiereguiluz added a commit that referenced this pull request Oct 15, 2018
This PR was squashed before being merged into the 2.8 branch (closes #10490).

Discussion
----------

Updated the command to run the Docker image

We merged #10131 but the command shown to serve the image locally doesn't work for me. I'm using Docker 18.06.0-ce. The change I made in this PR worked for me ... but we'd need the help of Docker experts to verify and discuss about the best possible command that will work under any circumstances. Thanks!

Commits
-------

f277bdf Updated the command to run the Docker image
@dkarlovi
Copy link
Contributor

@javiereguiluz you should recover the symfony username in either case. If you end up upgrading your CI builds to use Docker images in the future (for any Symfony-related project, not just Docs), it's where the images should end up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0