How to fix 'Hash Sum Mismatch' in Docker Ubuntu 18.04 image - docker

I'm trying to run docker container with ubuntu and nodejs to run some node application.
Firstly, I've searched for similar error of mine, and all didn't work for me.
For example, command below also have failed.
FROM ubuntu:18.04 as osbuild
RUN rm -rf /var/lib/apt/lists/* && \
apt-get clean && \
apt-get -y update && \
This is not my first time to use this Dockerfile (I almostly reused it), but it fails and I'm so confused.
I'm guessing problem might be update on bionic-things in Ubuntu 18.04 (Just yesterday night... suspicious), or maybe it is problem of docker for mac, but I don't see any possible solution for this problem.
I'm using macOS 10.14.6 and Docker 19.03.4
My Dockerfile is
FROM ubuntu:18.04 as osbuild
RUN apt-get -y update && \
...
It failed with following error message:
Err:14 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages
Hash Sum mismatch
...
Last modification reported: Sat, 09 Nov 2019 01:06:44 +0000
Release file created at: Sat, 09 Nov 2019 01:05:59 +0000

There was update on Ubuntu dist, including my problem dir.
Update was done at 2019-11-10 19:18, and now I can build docker image without error.

Related

Change time zone for docker and Dockerfile

I have an AWS EC2 instance that I have scheduled to open at 11:50 PM MST and close at 11:59 PM PST. I have set the timezone of the instance to MST so that I can run a cron job that executes a .sh file at 11:55 PM MST. The cron job is pretty simple: 55 23 * * * sudo bash docker run --mount type=bind,source="/home/ec2-user/environment/Project",target="/Project" myubuntu. The docker will mount to a local folder "Project" that contains a .cpp file that web scrapes data from Steam's user information page. The code within the .cpp file is very reliant on the current time/date, hence why I have gone through so much work to get everything running in MST so that everything is standard throughout. However, even with everything running on MST, when the docker container is running it is not in MST despite the dockerfile stating to run with ENV TZ="America/Salt Lake City", I have since changed it from Salt Lake City to Phoenix just to try it out but it still doesn't run the docker in MST. For example, when I run the docker at 9:22 PM MST Nov 24th, the date within the docker is 04:22 AM UTC Nov 25th. This slight date and time change is greatly affecting the code I am trying to run.
To kind of explain what the code does, Steam has a .json URL that holds about 48-62 hours worth of data in "[unix epoch time, # users logged in]". The goal is automation so I figured if I had the code cut out any data that did not match the date the code was run at, it would not be included in the data collection. So I am collecting 24 hours worth of data at a time by running the code at the very end of the day every single day. The difference in date/time between the MST time that both I and my EC2 instance are running on and the UTC time my docker is running on is causing data collection issues.
I was given the dockerfile by my professor, and it supposedly is set up to run on MST but it is not from what I can tell. I have tried to run my command within my .sh file with the included -v /etc/timezone:/etc/timezone but that does not seem to fix the timezone issue either. The dockerfile I was given is below:
# This image will be based on the ubuntu image. Build it using the
# command in the comment below. You may omit the ubuntu pull if you already
# did it. Before running the build, change into the directory containing
# this Dockerfile.
FROM ubuntu
# Set a default shell.
SHELL ["/bin/bash", "-c"]
# The timezone library stops the docker build and waits for user input to
# select a timezone. This breaks the build. To get around this,
# set up timezone information prior to installing that library. This
# Docker code does that. Composited from two sources:
# https://rtfm.co.ua/en/docker-configure-tzdata-and-timezone-during-build/
# https://serverfault.com/questions/949991/how-to-install-tzdata-on-a-ubuntu-docker-image
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ="America/Phoenix"
# Install a handful of useful libraries. Note that this is generally against
# best practices -- containers should be lean, and not include 'things you
# might use'. In our case, we're using the containers for development, so
# this may be reasonable here.
RUN apt-get -y update && apt-get -y install \
apt-utils \
emacs-nox \
g++
# Copy in the files from the current folder (recursively) For our purposes,
# put them in /cs3505
COPY . /cs3505
RUN apt-get -y install wget
Is there something I, or my professor, has done wrong in the setup of the docker to cause this timezone issue? How can I go about fixing my docker so that every time it runs at 11:55 PM MST it opens up with MST as the timezone?
Edit: I do not know if this makes a difference but running cat /etc/timezone returns "United States/Mountain" and running emacs /etc/timezone shows the same thing.
This is a dockerfile I customized based on Debian, you can refer to it:
FROM debian:stable-slim
ARG ARG_TIMEZONE=Asia/Shanghai
ENV ENV_TIMEZONE ${ARG_TIMEZONE}
# install base dependence
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections \
&& apt-get update && apt-get install -y -q \
dialog apt-utils \
locales systemd cron \
vim wget curl exuberant-ctags tree \
tzdata ntp ntpstat ntpdate \
&& apt-get clean && apt-get autoremove -y && rm -rf /var/lib/apt/lists/* \
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
# sync timezone
RUN echo '$ENV_TIMEZONE' > /etc/timezone \
&& ln -fsn /usr/share/zoneinfo/$ENV_TIMEZONE /etc/localtime \
&& dpkg-reconfigure --frontend noninteractive tzdata

Error: Unable to find a match in docker-dr-elephant build

I'm testing dr-elephant :
https://github.com/damienclaveau/docker-dr-elephant
But when i run :
docker build -t dr-elephant:2.0.6 .
I'm getting
Complete!
Last metadata expiration check: 0:00:19 ago on Thu Oct 24 07:51:21 2019.
No match for argument: krb5-auth-dialog
No match for argument: pam_krb5
Error: Unable to find a match
The command '/bin/sh -c yum install -y wget git unzip zip which && yum install -y krb5-server krb5-libs krb5-workstation && yum install -y krb5-auth-dialog pam_krb5 && yum install -y openssh-server openssh-clients && yum clean all' returned a non-zero code: 1
Any idea on how to fix this ?
Thanks
The error is right there: yum couldn't install packages named pam_krb5 and krb5-auth-dialog
You can easily test this by running the centos image and try to install those packages:
[root#228fcb9e4c19 /]# yum install -y krb5-auth-dialog pam_krb5
Failed to set locale, defaulting to C
CentOS-8 - AppStream 1.1 MB/s | 6.0 MB 00:05
CentOS-8 - Base 2.0 MB/s | 7.9 MB 00:03
CentOS-8 - Extras 634 B/s | 2.1 kB 00:03
No match for argument: krb5-auth-dialog
No match for argument: pam_krb5
Error: Unable to find a match
About how to fix this... you could try to remove that line (9 in the Dockerfile), but how do you know whether those packages were necessary by the app or not? So your best bet is to just contact the owner and tell him that his Dockerfile no longer works (it's 2 years old).
Usually this problem arises because the base image doesn't have a fixed version. You can check it's using FROM centos:latest, but today's centos is not the same as the centos of two years ago. You could also just try to edit the tag of the base image and use an older centos version, it might or might not work.

yum proxy error while creating a docker image

I have a dockerfile that should create a linux image and oracle database and few other things. However running the docker command i get the following error
http://yum.oracle.com/repo/OracleLinux/OL7/UEKR4/x86_64/repodata/repomd.xml:
[Errno 14] curl#5 - "Could not resolve proxy: www-proxy.us.oracle.com;
Unknown error"
I am creating this docker from inside a proxy and the proxy is appropriately setup in the environment and also in the dockerfile.
The lines from where i get this error are
yum install zip
yum -y install oracle-database-preinstall-18c
Interestingly, if i remove the yum commands and create a base docker and run the same yum commands from within the container, it works quite well.
# LICENSE UPL 1.0
# Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
FROM oraclelinux:7.4
MAINTAINER Temporary Name <temporary.name#oracle.com>
ENV JAVA_PKG=server-jre-8u*-linux-x64.tar.gz \
JAVA_HOME=/usr/java/default \
http_proxy=http://www-myproxy.cn.company.com:80 \
https_proxy=http://www-myproxy.cn.company.com:80 no_proxy=localhost,127.0.0.1,192.168.0.0/16,10.0.0.0/8,.cn.company.com,.companycorp.com,/var/run/docker.sock
RUN yum-config-manager --save --setopt=ol7_UEKR4.skip_if_unavailable=true && \
yum install zip && \
yum -y install oracle-database-preinstall-18c
Sorted this out with the help of a friend in my office. The issue was with the build command. I had to use the --network=host flag while 'build'ing docker.
I did the following
sudo docker build --build-arg http_proxy=http://www-proxy.cnt.company.com:80 -t oracle:183 .
instead of
sudo docker build --network=host --build-arg http_proxy=http://www-proxy.cnt.company.com:80 -t oracle:183 .
If someone faces a similar issue, please use --network flag to get that sorted.
Thanks
Bala

Installing docker-ce on Fedora 28

According to docker website, installation for Fedora should be as follow:
https://docs.docker.com/install/linux/docker-ce/fedora/#set-up-the-repository
However these instruction does not work for Fedora, and you get a frustrating message "Nothing to be done"
So how can I install Docker-ce on Fedora 28
From fedora 28 only the edge, test and nightly version are available.
To install docker-ce edge you can enable the edge repo:
dnf config-manager --set-disabled docker-ce-stable
dnf config-manager --set-enabled docker-ce-edge
dnf install docker-ce
At the writing of this answer, the repo of Docker did not contain a stable version for Fedora 28
The work around is to call:
sudo dnf install https://download.docker.com/linux/fedora/27/x86_64/stable/Packages/docker-ce-18.03.1.ce-1.fc27.x86_64.rpm
This will download the latest stable version at the writing of these lines.
Hope Docker will set a repo for Fedora 28 soon
I followed below steps on Fedora 28
Install DNF Plugins package
$ sudo dnf -y install dnf-plugins-core
--
Last metadata expiration check: 0:59:06 ago on Thu 05 Jul 2018 21:38:55 CDT.
Package dnf-plugins-core-2.1.5-4.fc28.noarch is already installed, skipping.
Dependencies resolved.
Nothing to do.
Complete!
Setup stable repository
$ sudo dnf config-manager \
--add-repo \
https://download.docker.com/linux/fedora/docker-ce.repo
--
Adding repo from: https://download.docker.com/linux/fedora/docker-ce.repo
Enable the edge and test repositories
$ sudo dnf config-manager --set-enabled docker-ce-edge
$ sudo dnf config-manager --set-enabled docker-ce-test
Install Docker CE
$ sudo dnf install docker-ce
....
Userid : "Docker Release (CE rpm) <docker#docker.com>"
Fingerprint: 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35
From : https://download.docker.com/linux/fedora/gpg
Start docker
$ sudo systemctl start docker
Verify installation
$ sudo docker run hello-world
If all goes well you should get
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
9bb5a5d4561a: Pull complete
Digest: sha256:3e1764d0f546ceac4565547df2ac4907fe46f007ea229fd7ef2718514bcec35d
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
installation for Fedora should be as follow
Fedora 28: A basic, simple way of getting docker-ce ...
cd /etc/yum.repos.d/
# dnf install https://download.docker.com/linux/fedora/docker-ce.repo
# dnf install docker-ce
You get version "18.03.1.ce.el7.centos" , I.e. the 'Enterprise' version.
EDIT : Also see the answer from #Sagi Forbes.

Unsatisfiable constraints when installing packages on docker alpine

I'm build a docker image based on ruby:2.3-alpine. I need to install couple of packages for my rails application to run normally. Unfortunately the following packages does not exists on alpine repositories.
What's the way to install them?
$ uname -a
Linux 50642453afd5 4.1.17-boot2docker #1 SMP Thu Feb 11 08:12:31 UTC 2016 x86_64 Linux
$ apk add iceweasel
ERROR: unsatisfiable constraints:
iceweasel (missing):
required by: world[iceweasel]
Packages to install:
libav-tools
xfonts-base
xfonts-75dpi
iceweasel
As of June, 2016 "firefox-esr" replaces Iceweasel.
Here's how to install it in an Alpine Docker container, and to run it to verify it's installed correctly:
FROM ruby:2.3-alpine
RUN apk add --no-cache firefox-esr
RUN firefox --version
You'll probably also need a virtual display (framebuffer) like xvfb. See this for more info => https://github.com/rickypc/docker-python-firefox-xvfb/blob/master/Dockerfile

Resources