When I try to build the following Dockerfile with the command line 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"]
I get an error at the time of building it: /bin/sh: 1: : not found
I am building an image in a macOS Hihg Sierra Version 10.13.6 but when I build the image in a linux CentOS environment (Inside another Docker container), the Dockerfile runs perfectly. The Docker version I am using on the mac is
- Client:
- Version: 18.06.1-ce
- API version: 1.38
- Server:
- Engine:
- Version: 18.06.1-ce
- API version: 1.38 (minimum version 1.12)
I have tried the following:
- Reinstall Docker on the mac
- apt-get update (without the -y)
- sudo apt-get update
- Do not update
- Do not create the conda environment
- Do not CMD
But i still get errors. How can the issue be solved?
UPDATE: The last lines before the error message appears during the building of the image are:
Get:6 http://security.debian.org/debian-security stretch/updates/main amd64 Packages [490 kB] Get:7 http://deb.debian.org/debian stretch-updates/main amd64 Packages [5476 B] Get:8 http://deb.debian.org/debian stretch/main amd64 Packages [9500 kB] Fetched 10.3 MB in 2s (4564 kB/s) Reading package lists... /bin/sh: 1: : not found
Docker returns a non-zero code: 127
In order to replicate the error, I am including a python script and a yml environment.
Python script all-my-python-files.py tested during an error:
# 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")
The environment.yml file is:
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 - cryptography=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 - requests=2.19.1 - urllib3=1.23 - ca-certificates=2018.8.24 - openssl=1.0.2p - time=1.7 - blas=1.0 - certifi=2018.8.24 - intel-openmp=2018.0.3 - libedit=3.1.20170329 - libffi=3.2.1 # - libgfortran=3.0.1 # Not running in 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 - pandas=0.23.4 - pip=10.0.1 - python=3.7.0 - python-dateutil=2.7.3 - pytz=2018.5 - readline=7.0 - setuptools=40.2.0 - six=1.11.0 - sqlite=3.24.0 - tk=8.6.8 - wheel=0.31.1 - xz=5.2.4 - zlib=1.2.11 # - libcxx=4.0.1 # Not running in linux # - libcxxabi=4.0.1 # Not running in linux - pip: - datetime==4.2 - zope.interface==4.5.0 prefix: /Users/Elias/miniconda3/envs/xlshp
set -x;
at the top of anyRUN
command that's failing is a good place to start. (Thus,RUN set -x; apt-get update -y
, orRUN set -x; conda update conda
). – Charles Duffy.bashrc
for services in general is a code smell..bashrc
is intended to be used to configure interactive shells, and is only guaranteed to be invoked for interactive shells (and not all interactive shells, but just the ones that aren't login shells). When you use it to configure a noninteractive service, you're Doing It Wrong. – Charles Duffy