Reputation: 1407
I need to run a docker container like the following:
docker run -p 80:80 -t container_name
but I'd like to specify the docker container in such a way that all I have to do is:
docker run container_name
When I EXPOSE 80, it doesn't seem to map it to the host. Also, I don't see any command that allows me to force -t (psuedo-tty) in the Dockerfile. CMD allows me to specify the command to run inside the container, but not the run parameters.
Thanks.
Upvotes: 0
Views: 985
Reputation: 488
Dockerfile is only about image creation. All informations about run containers need specify in run docker command.
The EXPOSE option in Dockerfile is only about -P option in run command. In that way the docker choose a random high port to map.
Upvotes: 1
Reputation: 14636
No, you can't do that.
Both arguments require the docker demon to interact with container and host.
-p 80:80
connects host and container network, -t
attaches the host's console to the container.
This is obviously not possible from within the container / the dockerfile.
Why don't you simply write a script that does that for you?
docker-run <container-name>
Upvotes: 1