当我尝试使用命令行docker build -t my-image-name .
FROM continuumio/miniconda3
EXPOSE 8880
# Set working directory
WORKDIR /my-workingdir
# Add scripts to docker workdir
ADD Dockerfile .
ADD environment.yml .
ADD all-my-python-files.py .
# Update & installation of linux packages
RUN apt-get update -y && \
apt-get install -y libgl1-mesa-glx apt-utils && \
apt-get install -y openssh-server && \
apt-get install -y net-tools
# Conda update and creation of environment
RUN conda update conda \
&& conda env create -f environment.yml \
# Activation of environment
&& echo "source activate environment" > ~/.bashrc
# Mount volumes
VOLUME /my-workingdir/Input
CMD ["python" , "execute_given_python_file.py"]
构建它时出现错误:/bin/sh: 1: : not found
我正在macOS Hihg Sierra版本10.13.6中构建映像,但是当我在Linux CentOS环境(在另一个Docker容器中)中构建映像时,Dockerfile可以完美运行。我在Mac上使用的Docker版本是
我尝试了以下方法:
但是我仍然会出错。该问题如何解决?
更新: 在生成映像期间,错误消息之前出现的最后几行是:
获取:6个http://security.debian.org/debian-security拉伸/更新/主要amd64软件包[490 kB] 获取:7 http://deb.debian.org/debian个拉伸更新/主要amd64软件包[5476 B] 获取:8个http://deb.debian.org/debian拉伸/主要amd64软件包[9500 kB] 以2s(4564 kB / s)的速度获取10.3 MB 正在阅读包裹清单... / bin / sh:1::找不到
Docker返回一个非零代码:127
为了复制错误,我提供了python脚本和yml环境。
在错误期间测试了Python脚本all-my-python-files.py:
# Name of file: all-my-python-files.py
import openpyxl
import requests
import datetime as dt
import time
from pandas.io.json import json_normalize
import argparse
import os
import pandas as pd
print("At this point, libraries should be imported")
print("End of python script")
environment.yml文件是:
name: environment
channels:
- statiskit
- anaconda
- conda-forge
- defaults
dependencies:
- asn1crypto=0.24.0
# For space the following line are not separated into single lines:
-cffi = 1.11.5 -chardet = 3.0.4 -密码= 2.3.1 -et_xmlfile = 1.0.1 -idna = 2.7 -jdcal = 1.4 -openpyxl = 2.5.5 -pycparser = 2.18 -pyopenssl = 18.0.0 -pysocks = 1.6.8 -请求= 2.19.1 -urllib3 = 1.23 -ca-certificates = 2018.8.24 -openssl = 1.0.2p -时间= 1.7 -blas = 1.0 -证书= 2018.8.24 -intel-openmp = 2018.0.3 -libedit = 3.1.20170329 -libffi = 3.2.1 #-libgfortran = 3.0.1#不在Linux中运行 -mkl = 2018.0.3 -mkl_fft = 1.0.4 -mkl_random = 1.0.1 -ncurses = 6.1 -numpy = 1.15.1 -numpy-base = 1.15.1 -熊猫= 0.23.4 -点= 10.0.1 -python = 3.7.0 -python-dateutil = 2.7.3 -pytz = 2018.5 -readline = 7.0 -setuptools = 40.2.0 -六个= 1.11.0 -sqlite = 3.24.0 -tk = 8.6.8 -车轮= 0.31.1 -xz = 5.2.4 -zlib = 1.2.11 #-libcxx = 4.0.1#不在Linux中运行 #-libcxxabi = 4.0.1#不在Linux中运行 -点: -datetime == 4.2 -zope.interface == 4.5.0 前缀:/ Users / Elias / miniconda3 / envs / xlshp
答案 0 :(得分:0)
正如@Charler Duffy所提到的,该问题与脚本中行的不可见结尾有关。以某种方式,通过以下方式编写代码可以解决问题:
RUN apt-get update
RUN apt-get install -y libgl1-mesa-glx apt-utils openssh-server net-tools
# Conda update and creation of environment
RUN conda update conda && \
conda env create -f environment.yml && \
# Activation of environment and correction of bash
echo "source activate xlshp_env" > ~/.bash
因此,当所有linux软件包都安装在同一行中时,Dockerfile可以构建映像。