gpt4 book ai didi

windows - docker 错误 : Container command not found or does not exist when running from Win10

转载 作者:可可西里 更新时间:2023-11-01 09:28:18 25 4
gpt4 key购买 nike

这让我发疯......

我有 Win10,我已经安装了 Docker 工具箱

Docker=1.10.2 
Compose=1.6.0
VirtualBox=5.0.14

我已经在 Linux [Amazon linux] 中成功启动了 LAMP,但是当我尝试做同样的事情时,终端响应 “错误:容器命令未找到或不存在”据我了解,Windows 解释 CMD 语法的方式有问题。

我试过了

 - CMD ["/run.sh"]
- ENTRYPOINT ["/run.sh"]
- CMD /run.sh
- CMD '/run.sh'
- CMD run.sh
- CMD "/run.sh"

但似乎没有任何效果。

注意:当我运行 CMD/run.sh 时,错误没有出现,但容器立即退出。

注意 2:我在 AWS 上尝试使用 Docker-Machine 设置 LAMP 时遇到了完全相同的问题

我有这个DockerfileLamp:

FROM ubuntu

# -- Install needed packages --
ENV DEBIAN_FRONTEND noninteractive

# -- Install additional utilities --
RUN apt-get update && \
apt-get install -y supervisor git curl apache2 mcrypt cron wget nano unzip

# -- Install PHP 5.5 --
RUN apt-get -y update && \
apt-get -y install php5 libapache2-mod-php5 mysql-server-5.5 php5-mysql pwgen php-apc php5-mcrypt php5-xdebug php5-gd php5-curl php-pear openssh-server php5-cli php5-apcu php5-intl php5-imagick php5-json

# -- Set localhost to apache conf file --
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf

# -- Add image configuration and scripts --
ADD ./lamp/start-apache2.sh /start-apache2.sh
ADD ./lamp/start-mysqld.sh /start-mysqld.sh
ADD ./lamp/run.sh /run.sh
RUN chmod 755 /*.sh
ADD ./lamp/my.cnf /etc/mysql/conf.d/my.cnf
ADD ./lamp/supervisord-apache2.conf
/etc/supervisor/conf.d/supervisord-apache2.conf
ADD ./lamp/supervisord-mysqld.conf
/etc/supervisor/conf.d/supervisord-mysqld.conf

# -- Remove pre-installed database --
RUN rm -rf /var/lib/mysql/*
# -- Add MySQL utils --
ADD ./lamp/setup_MySQL.sh /setup_MySQL.sh
RUN chmod 755 /*.sh

# -- config to enable .htaccess --
##ADD apache_default /etc/apache2/sites-available/000-default.conf
RUN a2enmod rewrite

# -- Environmental variables to configure php --
ENV PHP_UPLOAD_MAX_FILESIZE 10M
ENV PHP_POST_MAX_SIZE 10M

# -- Add volumes for MySQL --
##VOLUME ["/etc/mysql", "/var/lib/mysql" ]

# -- Set up SSH server --
RUN mkdir /var/run/sshd
RUN echo 'root:root' |chpasswd
RUN sed -ri 's/^PermitRootLogin\s+.*/PermitRootLogin yes/'
/etc/ssh/sshd_config
RUN sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config
ADD ./lamp/supervisord-openssh-server.conf
/etc/supervisor/conf.d/supervisord-openssh-server.conf

# -- Install Python & pip --
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y python python-pip python-dev && \
pip install --upgrade pip
# -- Install xvfb --
RUN apt-get install -y xvfb

EXPOSE 80 3306 22

CMD /run.sh

run.sh:

#!/bin/bash

VOLUME_HOME="/var/lib/mysql"

sed -ri -e "s/^upload_max_filesize.*/upload_max_filesize = ${PHP_UPLOAD_MAX_FILESIZE}/" \
-e "s/^post_max_size.*/post_max_size = ${PHP_POST_MAX_SIZE}/" /etc/php5/apache2/php.ini
if [[ ! -d $VOLUME_HOME/mysql ]]; then
echo "=> An empty or uninitialized MySQL volume is detected in $VOLUME_HOME"
echo "=> Installing MySQL ..."
mysql_install_db > /dev/null 2>&1
echo "=> Done!"
/setup_MySQL.sh
else
echo "=> Using an existing volume of MySQL"
fi

exec supervisord -n

docker-compose.yml:

lamp: # apache + mysql/php
build: .
dockerfile: DockerfileLamp
ports:
- "8181:80" # open apache to public
- "3333:3306" # open mysql to public
- "2222:22" # open SSH to public

最佳答案

Docker 是以进程为中心的,换句话说,当您的 CMD 脚本终止时,您的容器也会终止。在脚本运行结束时......

tail -f logfile (where logfile is some logfile you are interested in)

这将

1 - 停止你的容器退出2 - 允许你做

docker logs -f containerName

帮助你调试

3 - 允许您进入容器

docker exec -it bash containerName 

然后你可以运行你认为在容器内失败的命令并尝试解决这个问题

虽然这不能直接回答你的问题,但它应该给你足够的武器来解决这个问题

关于windows - docker 错误 : Container command not found or does not exist when running from Win10,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35889196/

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