ERROR: for xxx Cannot create container for service xxx: No command specified

问题:

ERROR: for high_mysql  Cannot create container for service high_mysql: No command specified
ERROR: Encountered errors while bringing up the project.


问题描述:

  • 利用docker的export和save分别对容器和镜像进行打包

root@miguan1:/opt/tpot/etc# docker export 512c649c07ba > a.tar
root@miguan1:/opt/tpot/etc# docker save new_1:v1 > b.tar
root@miguan1:/opt/tpot/etc# ls
a.tar  b.tar  compose  curator  logrotate  objects  tpot.yml
root@miguan1:/opt/tpot/etc# scp -r ./a.tar zeek@192.168.1.43:/home/zeek
zeek@192.168.1.43's password:
a.tar                                                                                       100%  567MB  90.6MB/s   00:06
root@miguan1:/opt/tpot/etc# scp -r ./b.tar zeek@192.168.1.43:/home/zeek
zeek@192.168.1.43's password:
b.tar  
                                                                                     100%  574MB  92.1MB/s   00:06

  •  分别生成新的镜像文件

root@miguan12:/opt# cat a.tar |docker import - new1:v1
sha256:55bd7ba312f7b73fa56f3dd81d408f5122efa1d828eb116b3f889e28282198d4
root@miguan12:/opt# docker load -i b.tar
d0f104dc0a1f: Loading layer [==================================================>]  72.49MB/72.49MB
316393412e04: Loading layer [==================================================>]  338.4kB/338.4kB
e9affce9cbe8: Loading layer [==================================================>]  9.539MB/9.539MB
e8fd11b2289c: Loading layer [==================================================>]    4.2MB/4.2MB
b55e8d7c5659: Loading layer [==================================================>]  1.536kB/1.536kB
ae39983d39c4: Loading layer [==================================================>]  53.76MB/53.76MB
f358b00d8ce7: Loading layer [==================================================>]  6.656kB/6.656kB
51b229f856aa: Loading layer [==================================================>]  3.584kB/3.584kB
7bab08caa6f2: Loading layer [==================================================>]  409.1MB/409.1MB
5395b9570fad: Loading layer [==================================================>]  5.632kB/5.632kB
3f1e7f3d4754: Loading layer [==================================================>]  16.38kB/16.38kB
6aba858f7ab9: Loading layer [==================================================>]  1.536kB/1.536kB
3baf2250f2e3: Loading layer [==================================================>]  52.34MB/52.34MB
e6d2bba89887: Loading layer [==================================================>]  28.67kB/28.67kB
d85e245a3df1: Loading layer [==================================================>]  9.728kB/9.728kB
Loaded image: new_1:v1
root@miguan12:/opt# docker images
REPOSITORY                 TAG                 IMAGE ID            CREATED             SIZE
new1                       v1                  55bd7ba312f7        6 minutes ago       588MB
new_1                      v1                  82985bcdcd96        22 hours ago        595MB


  • 镜像比较

红框以Cmd语令差异做出对比,可以利用docker inspect  镜像。可以看出,export的导出的镜像不带有容器运行时的第一条语令,save保存的镜像较为完整。原因:export导出的tar文件只是当前正在运行的容器,而包括docker run创建容器后/bin/sh -c后面的语令。

  • 分别测试镜像生成容器的情况

自定义tpot.yml文件:
high_mysql:
    container_name: high_mysql
    image: new1:v1   # --> 根据测试镜像不同进行更换 
    tty: true
    networks:
    - cowrie_local
    environment:
    - MYSQL_ROOT_PASSWORD=123456
    ports:
    - '3306:3306'
    read_only: true
    restart: 'no'
    tty: true
    volumes:
    - /data/mysql:/opt

(*)使用new1:v1镜像
root@miguan12:/opt/tpot/etc# docker-compose -f /opt/tpot/etc/tpot.yml up -d high_mysql
WARNING: Some networks were defined but are not used by any service: heralding_local, spiderfoot_local
Creating high_mysql ...
Creating high_mysql ... error

ERROR: for high_mysql  Cannot create container for service high_mysql: No command specified

ERROR: for high_mysql  Cannot create container for service high_mysql: No command specified
ERROR: Encountered errors while bringing up the project.

(*)验证
root@miguan12:/opt/tpot/etc# docker ps -a
CONTAINER ID        IMAGE                           COMMAND                  CREATED             STATUS                 PORTS

(*)使用new_1:v1镜像
root@miguan12:/opt/tpot/etc# docker-compose -f /opt/tpot/etc/tpot.yml up -d high_mysql
WARNING: Some networks were defined but are not used by any service: heralding_local, spiderfoot_local
Creating high_mysql ...
Creating high_mysql ... done

(*)验证
root@miguan12:/opt/tpot/etc# docker ps -a
CONTAINER ID        IMAGE                           COMMAND                  CREATED             STATUS                 PORTS                               NAMES
f967b9dfc2b3        new_1:v1                        "docker-entrypoint.s…"   38 seconds ago      Up 32 seconds          0.0.0.0:3306->3306/tcp, 33060/tcp   high_mysql

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值