Docker doesn't recognize the -p command all of

2019-08-27 01:21发布

问题:

So I just updated Docker on my Mac and getting adjusted to Docker seems to be quite challenging and confusing.

A few weeks ago, I was able to mind port 8834 on the docker container to port 8834 on my local host by running the following commands (this is my command line history):

 8450  docker attach -p 8834:8834 compassionate_chandrasekhar
 8452  docker start -p 8834:8834 compassionate_chandrasekhar

Today, if I try to do the same thing, the following happens:

[user:test.local:]$ docker container ps -a
CONTAINER ID        IMAGE                 COMMAND             CREATED             STATUS                     PORTS               NAMES
225146ec71d6        myuser/kali:kali   "/usr/bin/zsh"      9 minutes ago       Exited (0) 2 minutes ago                       agitated_fermat
e4389cac288a        myuser/kali:kali   "/usr/bin/zsh"      2 weeks ago         Exited (255) 2 weeks ago                       suspicious_hypatia
265f2c9215c5        myuser/kali:kali   "/usr/bin/zsh"      2 weeks ago         Exited (0) 2 weeks ago                         hungry_poincare
34b36b4d8a7e        myuser/kali:kali   "/usr/bin/zsh"      2 weeks ago         Created                                        amazing_stonebraker

followed by:

[user:test.local:]$ docker start -p 8834:8834 agitated_fermat
unknown shorthand flag: 'p' in -p
See 'docker start --help'.

What am I doing wrong? Extremely confusing

回答1:

Publishing ports can be done only with newly created containers not existing containers. So you need to stop the container and create a new one with the port you need



标签: docker