本文介绍了Docker突然无法识别-p命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我刚刚在Mac上更新了Docker,并且适应Docker似乎是充满挑战和困惑的.

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

几周前,我可以通过运行以下命令(这是我的命令行历史记录)来介意docker容器上的端口8834到本地主机上的端口8834:

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

其次:

[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

推荐答案

只能使用新创建的容器而不是现有容器来完成发布端口.因此,您需要停止容器并使用所需的端口创建一个新容器

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突然无法识别-p命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 15:10