Docker入口点和cmd在一起 [英] Docker entrypoint and cmd together

查看:48
本文介绍了Docker入口点和cmd在一起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试同时设置入口点和cmd的Docker.

I try to setup a Docker with both entrypoint and cmd.

FROM debian:stretch
RUN apt-get update && \
apt install gnupg ca-certificates -y 
RUN echo "deb http://repo.aptly.info/ squeeze main" > /etc/apt/sources.list.d/aptly.list
RUN apt-key adv --keyserver keys.gnupg.net --recv-keys 9E3E53F19C7DE460
RUN apt update && apt install aptly -y
ADD aptly.conf /etc/aptly.conf
ADD start.sh .
VOLUME ["/aptly"]
ENTRYPOINT ["/start.sh"]
CMD ["aptly", "api", "serve"]

但是入口点脚本没有停止...cmd命令未启动

But entrypoint script is not stopping... The cmd command is not launching

这是我的脚本:

#!/bin/bash
 set -e 
 init_aptly() { 
 #import pgp key
#create nginx root folder in /aptly
su -c "mkdir -p /aptly/.aptly/public"
echo "12"
 #initialize repository
 #aptly create repo doze-server -   distribution="stable"
  }
  #check for first run
 if [ ! -e /aptly/.aptly/public ]; then
  init_aptly
  echo "13"
 fi
  echo "14"

该脚本始终回显14,我只想要一个,然后从dockerfile执行cmd命令

The script always echo 14, I would like only one and then, execute the cmd command from dockerfile

推荐答案

同时使用入口点和命令时,命令部分将作为参数附加到入口点可执行文件中.因此,在您的情况下:

When you use both entrypoint and command, the command section will be appended to entrypoint executable as arguments. Thus in your case:

ENTRYPOINT ["/start.sh"]
CMD ["aptly", "api", "serve"]

等同于运行:

ENTRYPOINT["/start.sh", "aptly", "api", "serve"]

这篇关于Docker入口点和cmd在一起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆