gpt4 book ai didi

mysql - Docker 无法启动没有这样的文件或目录的容器

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:13:45 27 4
gpt4 key购买 nike

我无法在构建后启动我的容器,我得到了:

Error response from daemon: Cannot start container ogc-mysql: no such file or directory
Error: failed to start one or more containers

这是我的 Docker 文件:

FROM ubuntu:latest

MAINTAINER Davin Kevin

# Install latest updates
RUN apt-get update
RUN apt-get upgrade -y

# Install mysql client and server
RUN apt-get -y install mysql-client mysql-server curl

# Enable remote access (default is localhost only, we change this
# otherwise our database would not be reachable from outside the container)
RUN sed -i -e"s/^bind-address\s*=\s*127.0.0.1/bind-address = 0.0.0.0/" /etc/mysql/my.cnf

# Install database
ADD ./database.sql /var/db/database.sql

# Set Standard settings
ENV user ogc
ENV password ogc
ENV url file:/var/db/database.sql
ENV right READ

# Install starting script
ADD ./start-database.sh /usr/local/bin/start-database.sh
RUN chmod +x /usr/local/bin/start-database.sh

EXPOSE 3306

CMD ["/usr/local/bin/start-database.sh"]

我的 sh 脚本只做:

docker build -t ogc-mysql .
docker run --name ogc-mysql -d -p 3306:3306 ogc-mysql

引用 Docker 文档:

docker build will return a no such file or directory error if the file or directory does not exist in the uploaded context. This may happen if there is no context, or if you specify a file that is elsewhere on the Host system. The context is limited to the current directory (and its children) for security reasons, and to ensure repeatable builds on remote Docker hosts. This is also the reason why ADD ../file will not work.

此命令:docker ps -a 返回:

CONTAINER ID : 70..
IMAGE : ogc-sql:latest
COMMAND : "/usr/local/bin/star"
CREATED : 13 seconds ago
STATUS : /
PORTS : /
NAMES : ogc-mysql

事实是这个命令在 Mac OS 上成功运行..

最佳答案

我在使用 CMD 集成和调用 shell 脚本时得到了这个,它在我的容器中有 Windows 换行符 (CR+LF)。

在转换为 Linux 行尾(仅限 LF)并重建容器后,它就可以正常启动了。

关于mysql - Docker 无法启动没有这样的文件或目录的容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26842629/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com