【发布时间】:2022-08-10 14:48:38
【问题描述】:
尝试通过 dockerfile 运行 cron,但是在运行容器时它会退出。下面是我的 dockerfile 和错误。任何帮助将非常感激
错误:
docker:来自守护进程的错误响应:OCI 运行时创建失败:container_linux.go:380:启动容器进程导致:exec:\“cron\”:$PATH 中找不到可执行文件:未知。
Dockerfile:
# Pull base image.
FROM amazonlinux:2
ARG TERRAFORM_VERSION=1.2.6
RUN \\
yum update -y && \\
yum install unzip -y && \\
yum install wget -y && \\
yum install vim -y \\
yum install bash -y
################################
# Install Terraform
################################
# Download terraform for linux
RUN wget https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip
RUN unzip terraform_${TERRAFORM_VERSION}_linux_amd64.zip
RUN mv terraform /usr/local/bin/
################################
# Install python
################################
RUN yum install -y python3-pip
RUN pip3 install --upgrade pip
################################
# Install AWS CLI
################################
RUN pip install awscli --upgrade --user
# add aws cli location to path
ENV PATH=~/.local/bin:$PATH
RUN mkdir ~/.aws && touch ~/.aws/credentials
################################
# Install Cron
################################
RUN yum -y install ca-certificates shadow-utils cronie && yum -y clean all
# Creating crontab
COPY ./automation.sh /var/automation.sh
# Giving executable permission to script file.
RUN chmod +x /var/automation.sh \\
&& echo \"* * * * * /bin/bash /var/automation.sh\" >> /var/crontab
# Ensure sudo group users are not asked for a password
RUN echo \'%sudo ALL=(ALL) NOPASSWD:ALL\' >> \\
/etc/sudoers
#run cron process through cmd
CMD [\"cron\", \"-f\"]
标签: docker cron dockerfile devops