Reputation: 927
1: docker run -d -p 3000:3000 images
If i up a localhost:3000
server in container,how can i open it in my machine browser, what's the ip?
I've tried localhost:3000
or 0.0.0.0:3000
.
2: I use docker pull ubuntu
and docker run
it, after updating and deploying the server i commmited it.So now i have one ubuntu
and a new image.
Next time i run a container using this new image, The shell scripts still needs to be sourced, also the server needs to reopened again.
How can i commit the image that it can source the scripts and deployed by itself when i docker run
it.
Thanks.
Upvotes: 1
Views: 187
Reputation: 56617
I don't quite understand questions 2 or 3, can you add more context?
Regarding your question about using -p
, you should be able to visit in your browser using http://localhost:3000/ . However that assumes a couple of things are true.
First, you used -p 3000:<container-port>
- looks good on this point.
Second, the image you have run exposed port 3000 (EXPOSE 3000
).
And third, the service running in the container is listening on 0.0.0.0:3000
. If it is listening on localhost inside the container, then the port export will not work. Each container has its own localhost which is usable only inside the container. So it needs to be listening on all IPs inside the container, in order for outside connections to reach the service from outside of the container.
Upvotes: 1