docker run报 docker: Error response from daemon: no command specified.

docker run报 docker: Error response from daemon: no command specified.

1. export出mysql的container为tar, 拷贝到另一台虚拟机, import该tar为image, docker run该image时报 docker: Error response from daemon: no command specified. 时间240211

export出mysql的container为tar, 拷贝到另一台虚拟机, import该tar为image, docker run该image时报 docker: Error response from daemon: no command specified. 时间240211

如果在run句后加bash或/bin/bash, 可以run, 但exec后容器中的mysql不启动

查看原先container的COMMAD, 用docker psdocke ps -a 查看时, COMMAND列短,没法看到全部, 可以加 --no-trunc 参数 Don’t truncate output 不要截断输出

sudo docker ps -a --no-trunc

也可以写成

sudo docker ps -a --no-trunc
sudo docker container ls -a --no-trunc
sudo docker container list -a --no-trunc

对比

z@us2243:/root$ sudo docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED        STATUS        PORTS                                                  NAMES
7cfd759ca381   mysql:8.0.36   "docker-entrypoint.s…"   21 hours ago   Up 21 hours   33060/tcp, 0.0.0.0:8036->3306/tcp, :::8036->3306/tcp   Mysql8036p8036
z@us2243:/root$ sudo docker ps --no-trunc
CONTAINER ID                                                       IMAGE          COMMAND                         CREATED        STATUS        PORTS                                                  NAMES
7cfd759ca3819ab95ccdb2c5672f88cb71018bbe69cf16f90b42134dc56a0fd0   mysql:8.0.36   "docker-entrypoint.sh mysqld"   21 hours ago   Up 21 hours   33060/tcp, 0.0.0.0:8036->3306/tcp, :::8036->3306/tcp   Mysql8036p8036

可看到COMMAND为 docker-entrypoint.sh mysqld

在run句后加上 docker-entrypoint.sh mysqld

sudo docker run -itd   --name Mysql8036p8036   -p 8036:3306   -e MYSQL_ALLOW_EMPTY_PASSWORD='root'   mysql:8.0.36   docker-entrypoint.sh mysqld

问题解决

你可能感兴趣的:(虚拟机,容器,docker,容器,运维)