For some reason, I've been unable to complete a docker build without the process stopping and no error being provided. I've googled around, and no-one appears to have the same issue.
The first (and salient) part of the Dockerfile config I'm using:
FROM java:8-jre
ENV DEBIAN_FRONTEND noninteractive
# Install needed packages
RUN apt-get update
RUN apt-get install -y \
cron
The command I'm using to execute the build (build.cmd):
#ECHO OFF
docker --debug --log-level debug build . ^
--build-arg http_proxy=%http_proxy% ^
--build-arg https_proxy=%https_proxy% ^
--build-arg no_proxy=%no_proxy% ^
--tag "bravura/jfrog-mission-control:latest" ^
%*
The result of running it:
Sending build context to Docker daemon 133.9MB
Step 1/7 : FROM java:8-jre
---> e44d62cf8862
Step 2/7 : ENV DEBIAN_FRONTEND noninteractive
---> Using cache
---> f30e6ab20920
Step 3/7 : RUN apt-get update
---> Running in 677bd445e48c
Get:1 http://security.debian.org jessie/updates InRelease [63.1 kB]
Get:2 http://security.debian.org jessie/updates/main amd64 Packages [508 kB]
Ign http://deb.debian.org jessie InRelease
Get:3 http://deb.debian.org jessie-updates InRelease [145 kB]
Get:4 http://deb.debian.org jessie-backports InRelease [166 kB]
Get:5 http://deb.debian.org jessie Release.gpg [2373 B]
Get:6 http://deb.debian.org jessie Release [148 kB]
Get:7 http://deb.debian.org jessie-updates/main amd64 Packages [17.6 kB]
Get:8 http://deb.debian.org jessie-backports/main amd64 Packages [1150 kB]
Get:9 http://deb.debian.org jessie/main amd64 Packages [9065 kB]
Fetched 11.3 MB in 6s (1829 kB/s)
Reading package lists...
SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.
Here's the big one: Running the same set of commands in a shell brought up by running docker run -it --rm java:8-jre /bin/bash works perfectly fine.
The other interesting bit: Concatenating the two commands together (with &&) defers the exit to the end of both executions. In fact, no errors are actually produced, so appending additional commands to the end works just fine (e.g. apt-get update && apt-get install -y cron && echo "Done!")
Any help even identifying where the issue could be reported would be greatly appreciated.
Update: As is the way with these things, I thought to look in the service logs as soon as I posted this. Found the following tidbits that might point me in the right direction:
[13:50:31.818][ApiProxy ][Info ] error copying response body from Docker: unexpected EOF
[13:50:31.818][ApiProxy ][Info ] error closing response body from Docker: unexpected EOF
Still no real idea what it means, however. Might just be another symptom rather than a cause.
Update: Just ran the build again to double-check the submitted responses, and without changes to my Dockerfile, everything is now working beautifully. One possible option is that the issue was silently fixed in the last update (which I installed today). I don't really have time to revert and re-test, so this is it until I run into the issue again, or someone else gets the same thing.
unexpected EOF (end of file). it seems you forgot the "\" at the end of your RUN command.
RUN apt-get update && apt-get install -y cron && echo "Done!" \
or
RUN apt-get update && \
apt-get install -y cron && \
echo "Done!" \
#Tzrlk are you working behind the corporate proxy? Try running this command directly in your terminal first and then use the docker build command and see.
export http_proxy=http://your proxy here:port here
export https_proxy=http://your proxy here:port here
Related
I'm trying to run docker compose stack using Docker Engine Windows service, installed with dockerd.exe --register-service. When I run docker compose up I get the following log:
Step 4/14 : RUN apt-get update
---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (windows/amd64) and no specific platform was requested
---> Running in 7e50524784b1
Get:1 http://deb.debian.org/debian bullseye InRelease [116 kB]
Get:2 http://deb.debian.org/debian-security bullseye-security InRelease [48.4 kB]
Get:3 http://deb.debian.org/debian bullseye-updates InRelease [44.1 kB]
Get:4 http://deb.debian.org/debian bullseye/main amd64 Packages [8184 kB]
Get:5 http://deb.debian.org/debian-security bullseye-security/main amd64 Packages [186 kB]
Get:6 http://deb.debian.org/debian bullseye-updates/main amd64 Packages [6344 B]
Fetched 8585 kB in 15s (578 kB/s)
Reading package lists...
1 error occurred:
* Status: The command '/bin/sh -c apt-get update' returned a non-zero code: 4294967295: failed to shutdown container: container 7e50524784b12e1c4f94537b3a700ae61eb35bdc597b0d277c750b203dae97e4 encountered an error during hcsshim::System::waitBackground: failure in a Windows system call: The virtual machine or container with the specified identifier is not running. (0xc0370110): subsequent terminate failed container 7e50524784b12e1c4f94537b3a700ae61eb35bdc597b0d277c750b203dae97e4 encountered an error during hcsshim::System::waitBackground: failure in a Windows system call: The virtual machine or container with the specified identifier is not running. (0xc0370110), Code: 4294967295
Dockerfile:
# syntax=docker/dockerfile:1
FROM python:3.10-bullseye
WORKDIR /app
COPY Pipfile Pipfile
RUN apt-get update
RUN apt-get install ffmpeg libsm6 libxext6 -y
RUN pip install pipenv
RUN pipenv install
COPY . .
ENV STREAMLIT_BROWSER_GATHER_USER_STATS=false
ENV STREAMLIT_SERVER_MAX_UPLOAD_SIZE=2000
ENV STREAMLIT_SERVER_RUN_ON_SAVE=true
ENV STREAMLIT_SERVER_HEADLESS=true
CMD ["pipenv", "run", "streamlit", "run", "src/main.py"]
EXPOSE 8501
docker-compose.yml:
version: "1.27.0+"
services:
app:
build: .
ports:
- "8501"
platform: linux/amd64
volumes:
- .:/app
Also before getting these errors, I received this, which I solved by running dockerd -experimental. And error that it can't find linux containers, which I solved by this.
I believe your problem is that dockerd on Windows will try to run Windows containers, not Linux. When using Docker desktop, it changes the context to use WSL 2 for Linux containers and HCSv1 for Windows containers. I'm not sure if you can set up dockerd directly. What is the environment? Is it a Windows client or Server?
I am trying to create a docker image which includes an installed Firefox browser, using openjdk:11-slim or openjdk:11 as my base image.
This is a minimal reproducible example of my dockerfile:
FROM openjdk:11
RUN rm -rf /var/lib/apt/lists/* && \
apt-get update && apt-get install -y --no-install-recommends firefox
Here is the output of running docker build .:
$ docker build -t testing/simpleopenjdkfirefox .
Sending build context to Docker daemon 2.048kB
Step 1/2 : FROM openjdk:11
---> 1eec9f9fe101
Step 2/2 : RUN rm -rf /var/lib/apt/lists/* && apt-get update && apt-get install -y --no-install-recommends firefox
---> Running in da4e93ffe4a1
Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB]
Get:2 http://deb.debian.org/debian buster InRelease [121 kB]
Get:3 http://deb.debian.org/debian buster-updates InRelease [51.9 kB]
Get:4 http://security.debian.org/debian-security buster/updates/main amd64 Packages [268 kB]
Get:5 http://deb.debian.org/debian buster/main amd64 Packages [7907 kB]
Get:6 http://deb.debian.org/debian buster-updates/main amd64 Packages [7860 B]
Fetched 8422 kB in 2s (4114 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
Package firefox is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'firefox' has no installation candidate
The command '/bin/sh -c rm -rf /var/lib/apt/lists/* && apt-get update && apt-get install -y --no-install-recommends firefox' returned a non-zero code: 100
My reasons to believe that running apt-get install firefox should be possible are:
Firefox is visible as a package on both the Debian Packages (https://packages.debian.org/search?keywords=firefox) and the Ubuntu Packages (https://packages.ubuntu.com/search?keywords=firefox&searchon=names&suite=groovy§ion=all)
apt install firefox works on an Ubuntu machine (just CLI, no docker involved)
In the dockerfile, replacing firefox with wget works. This means that apt-get is working as intended, and something is specifically incompatible with firefox.
I've tried using the following base images:
openjdk:11-slim - my desired base image for what I'm working on
openjdk:11 - the full de facto openjdk image, should be the default working case
openjdk:11-buster - to see if Debian 10 would work
Why does the apt-get install fail in the docker build, but not in the Ubuntu CLI?
Is the issue Linux OS compatibility or something else?
The firefox package is only available under the Debian Unstable Repository (codename "Sid"). Debian Stable only has firefox-esr. To include the Sid repository in the package index update, you must add deb http://deb.debian.org/debian/ unstable main contrib non-free as a repository source for apt.
echo "deb http://deb.debian.org/debian/ unstable main contrib non-free" >> /etc/apt/sources.list.d/debian.list
apt-get update
apt-get install -y --no-install-recommends firefox
If the Sid repository does not have an up-to-date version of Firefox, the next best place to check are the Firefox PPAs (Personal Package Archive) operated by the Mozilla team themselves. PPAs are just repositories, and are added the exact same way as the Sid repository above:
Firefox PPA
Firefox Next PPA
For example,
sudo add-apt-repository ppa:mozillateam/firefox-next
sudo apt-get update
I am trying to create a Docker image of Cassandra. Cassandra requires Java. I have added line to install java. In my Docker file
FROM ubuntu:20.04
RUN apt-get update
RUN apt-get install default-jre
COPY apache-cassandra-3.11.6-bin.tar.gz .
RUN tar -xzf apache-cassandra-3.11.6-bin.tar.gz
RUN chmod -R 777 apache-cassandra-3.11.6
RUN ls
RUN echo $PATH
RUN echo $PWD
RUN apt update
#RUN apt-get install openjdk-7-jdk
#RUN java -version
WORKDIR apache-cassandra-3.11.6
RUN ls
ENV CASSANDRA_HOME=/apache-cassandra-3.11.6
ENV PATH=$PATH:$CASSANDRA_HOME/bin
RUN echo $PATH
RUN ls
WORKDIR apache-cassandra-3.11.6/bin
RUN ls
CMD ["cassandra","-f"]
I am getting error in apt-get update and apt. How can I fix this?
C:\Users\manuc\Documents\manu\cassandra_image_test>docker build -f CassandraImageDockerFile.txt -t manucassandra .
Sending build context to Docker daemon 184.8MB
Step 1/19 : FROM ubuntu:20.04
---> 74435f89ab78
Step 2/19 : RUN apt-get update
---> Running in b395852c8e6b
Get:1 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]
Get:2 http://security.ubuntu.com/ubuntu focal-security InRelease [107 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease [107 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease [98.3 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal/restricted amd64 Packages [33.4 kB]
Get:6 http://archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages [177 kB]
Get:7 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages [11.3 MB]
Get:8 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages [1275 kB]
Reading package lists...
E: Release file for http://archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease is not valid yet (invalid for another 1d 13h 27min 45s). Updates for this repository will not be applied.
E: Release file for http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease is not valid yet (invalid for another 1d 12h 39min 24s). Updates for this repository will not be applied.
E: Release file for http://archive.ubuntu.com/ubuntu/dists/focal-backports/InRelease is not valid yet (invalid for another 1d 12h 39min 54s). Updates for this repository will not be applied.
The command '/bin/sh -c apt-get update' returned a non-zero code: 100
This seems to be an issue with your timezone. Please restart your Docker host.
Docker Desktop:
You can manually restart it using UI.
Docker machine:
$ docker-machine restart <DOCKER-MACHINE-NAME>
Podman:
$ podman restart <PODMAN-MACHINE-NAME>
I'm using the Visual Studio Code Remote - Containers extension with a customized DockerFile. It is based on https://github.com/microsoft/vscode-dev-containers/blob/master/containers/python-3/.devcontainer/Dockerfile but uses a different base image and doesn't try to pip install from requirements.txt.
When I build the container in vscode, with PostCreateCommand set to "python --version", the following errors appears in the dev containers terminal output:
Run: docker exec -w /workspaces/media-classifier dd5e552b4f113ecf74504cc6d3aed3ca1727b4a172645515392c4632b7c45b81 /bin/sh -c python --version
/bin/sh: 1: python: not found
postCreateCommand "python --version" failed.
I've tried using the same setting value for PostCreateCommand (python --version) using both the standard python3 container and the python3 anaconda container and they both successfully output the python version.
I've also tried setting PostCreateCommand to the following values, which all produce the same 'not found' error:
pip --version
conda --version
When the container has started, I'm successfully able to use python, pip and conda so they are definitely installed.
Dockerfile
FROM microsoft/cntk:2.6-cpu-python3.5
# Configure apt and install packages
RUN apt-get update \
&& apt-get -y install --no-install-recommends apt-utils 2>&1 \
#
# Verify git, process tools, lsb-release (common in install instructions for CLIs) installed
&& apt-get -y install git procps lsb-release \
# Clean up
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
devcontainer.json
{
"name": "CNTK Python3.5",
"context": "..",
"dockerFile": "Dockerfile",
// Uncomment the next line if you want to publish any ports.
// "appPort": [],
// Uncomment the next line to run commands after the container is created.
"postCreateCommand": "python --version",
"extensions": [
"ms-python.python",
"neuron.neuron-ipe"
],
"settings": {
"python.pythonPath": "/opt/conda/bin/python",
"python.linting.pylintEnabled": true,
"python.linting.enabled": true
}
}
I'm expecting PostCreateCommand to execute successfully and output the python version installed in whichever anaconda environment is active at the time.
you are trying to run python when python3 is installed
try running
python3 --version
Since python3 is not a direct replacement for python v2, Debian based systems have not setup an automatic alias to point python to the python3 binaries. The recommended solution is to point all python v3 commands to python3. The workaround for applications that can't be easily updated is to setup an alias to point python to python3 anyway.
FROM microsoft/cntk:2.6-cpu-python3.5
# Configure apt and install packages
RUN apt-get update \
&& apt-get -y install --no-install-recommends apt-utils 2>&1 \
#
# Verify git, process tools, lsb-release (common in install instructions for CLIs) installed
&& apt-get -y install \
git \
lsb-release \
procps \
python-is-python3 \
# Clean up
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
For more on this, see https://askubuntu.com/questions/320996/how-to-make-python-program-command-execute-python-3
From the comments, here's a similar example with a different base image, also fixed by installing python-is-python3:
$ docker run -it --rm --entrypoint bash mcr.microsoft.com/vscode/devcontainers/dotnet:0.202.1-6.0
Unable to find image 'mcr.microsoft.com/vscode/devcontainers/dotnet:0.202.1-6.0' locally
0.202.1-6.0: Pulling from vscode/devcontainers/dotnet
e5ae68f74026: Pull complete
a74667493539: Pull complete
3a0bffe13264: Pull complete
913bac4f4fc9: Pull complete
d2ea5cb43486: Pull complete
1414be57e953: Pull complete
868d7bfddf03: Pull complete
63ab446ca68f: Pull complete
1259b98fc625: Pull complete
802a0f1d31f7: Pull complete
094ecb532868: Pull complete
f643f7ed0620: Pull complete
Digest: sha256:d3bfb3e7c9ecfcb4472b59272e2f8857807667c0bd83fb1da935d28e9087e733
Status: Downloaded newer image for mcr.microsoft.com/vscode/devcontainers/dotnet:0.202.1-6.0
root ➜ / $ type python
bash: type: python: not found
root ➜ / $ type python3
python3 is /usr/bin/python3
root ➜ / $ apt-get update
Get:1 http://security.debian.org/debian-security bullseye-security InRelease [44.1 kB]
Get:2 http://deb.debian.org/debian bullseye InRelease [116 kB]
Get:3 http://deb.debian.org/debian bullseye-updates InRelease [39.4 kB]
Get:4 https://dl.yarnpkg.com/debian stable InRelease [17.1 kB]
Get:5 http://security.debian.org/debian-security bullseye-security/main amd64 Packages [102 kB]
Get:6 http://deb.debian.org/debian bullseye/contrib amd64 Packages [50.5 kB]
Get:7 http://deb.debian.org/debian bullseye/main amd64 Packages [8183 kB]
Get:8 https://dl.yarnpkg.com/debian stable/main all Packages [10.5 kB]
Get:9 https://dl.yarnpkg.com/debian stable/main amd64 Packages [10.5 kB]
Get:10 http://deb.debian.org/debian bullseye/non-free amd64 Packages [93.8 kB]
Get:11 http://deb.debian.org/debian bullseye-updates/main amd64 Packages [2592 B]
Fetched 8670 kB in 3s (3246 kB/s)
Reading package lists... Done
root ➜ / $ apt-get install -y python-is-python3
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
python-is-python3
0 upgraded, 1 newly installed, 0 to remove and 13 not upgraded.
Need to get 2800 B of archives.
After this operation, 13.3 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bullseye/main amd64 python-is-python3 all 3.9.2-1 [2800 B]
Fetched 2800 B in 0s (67.0 kB/s)
Selecting previously unselected package python-is-python3.
(Reading database ... 22711 files and directories currently installed.)
Preparing to unpack .../python-is-python3_3.9.2-1_all.deb ...
Unpacking python-is-python3 (3.9.2-1) ...
Setting up python-is-python3 (3.9.2-1) ...
Processing triggers for man-db (2.9.4-2) ...
root ➜ / $ type python
python is /usr/bin/python
I have Dockerfile that I have used many times without an issue. Now I need to add some packages to it (ssmtp and sendmail) and when I add them the build fails with:
Sending build context to Docker daemon 645.3 MB
Sending build context to Docker daemon
Step 0 : FROM debian:jessie
---> 736e5442e772
Step 1 : MAINTAINER Larry Martell <larry.martell#foo.com>
---> Using cache
---> bd272aa26940
Step 2 : ENV HOME /opt/django/CAPgraph/
---> Using cache
---> 1c540ed91808
Step 3 : RUN echo "deb http://http.debian.net/debian jessie-backports main" >> /etc/apt/sources.list
---> Using cache
---> 8788d48e625d
Step 4 : RUN (apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential git python python-dev python-setuptools nginx sqlite3 supervisor mysql-server libmysqlclient-dev vim cron unzip software-properties-common python-software-properties openjdk-8-jre xvfb wkhtmltopdf ssmtp sendmail)
---> Running in 8986bca93fdb
Get:1 http://security.debian.org jessie/updates InRelease [63.1 kB]
Get:2 http://security.debian.org jessie/updates/main amd64 Packages [436 kB]
Get:3 http://http.debian.net jessie-backports InRelease [166 kB]
Get:4 http://httpredir.debian.org jessie-updates InRelease [145 kB]
Get:5 http://http.debian.net jessie-backports/main amd64 Packages [1031 kB]
Get:6 http://httpredir.debian.org jessie-updates/main amd64 Packages [17.6 kB]
Ign http://httpredir.debian.org jessie InRelease
Get:7 http://httpredir.debian.org jessie Release.gpg [2373 B]
Get:8 http://httpredir.debian.org jessie Release [148 kB]
Get:9 http://httpredir.debian.org jessie/main amd64 Packages [9049 kB]
Fetched 11.1 MB in 9s (1211 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
sendmail : Depends: sendmail-bin but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
The command '/bin/sh -c (apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential git python python-dev python-setuptools nginx sqlite3 supervisor mysql-server libmysqlclient-dev vim cron unzip software-properties-common python-software-properties openjdk-8-jre xvfb wkhtmltopdf ssmtp sendmail)' returned a non-zero code: 100
If I add those packages to the list I then complains about others. What does this 'held broken packages' message mean and how do I fix it?
Here is the first part of my Dockerfile:
FROM debian:jessie ENV HOME /opt/django/CAPgraph/
RUN echo "deb http://http.debian.net/debian jessie-backports main" >> /etc/apt/sources.list
RUN (apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential git python python-dev python-setuptools nginx sqlite3 supervisor mysql-server libmysqlclient-dev vim cron unzip software-properties-common python-software-properties openjdk-8-jre xvfb wkhtmltopdf sendmail ssmtp)
I tried adding sendmail-bin and then it failed with:
The following packages have unmet dependencies:
sendmail-bin : Conflicts: mail-transport-agent
ssmtp : Conflicts: mail-transport-agent
E: Unable to correct problems, you have held broken packages.
I then added mail-transport-agent and it failed with:
Package mail-transport-agent is a virtual package provided by:
opensmtpd 5.7.3p2-1~bpo8+1
ssmtp 2.64-8
sendmail-bin 8.14.4-8+deb8u1
qmail-run 2.0.2+nmu1
postfix 2.11.3-1
nullmailer 1:1.13-1+deb8u1
msmtp-mta 1.4.32-2
masqmail 0.2.30-1
lsb-invalid-mta 4.1+Debian13+nmu1
exim4-daemon-light 4.84.2-2+deb8u3
exim4-daemon-heavy 4.84.2-2+deb8u3
esmtp-run 1.2-12
dma 0.9-1
courier-mta 0.73.1-1.6
citadel-mta 8.24-1+b3
E: Package 'mail-transport-agent' has no installation candidate
Debian is setup to only allow one mail transport agent, and your install command is trying to include two, ssmtp and sendmail/sendmail-bin. Since they conflict with each other, you'll need to remove one of these from your install command.
If the sendmail dependency is so your Python app can send email via the sendmail binary, just install ssmtp and configure it to use an external MTA.
Trying to run sendmail in a Docker container is not recommended