I have a Docker file containing:
FROM ubuntu
MAINTAINER Zeinab Abbasimazar
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends apt-utils
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y wget unzip curl aptitude
RUN aptitude search curl
RUN VERSION=$(curl myURL 2>&1 | grep -o -E 'href="([^"#]+)"' | cut -d'"' -f2 | egrep component-[0-9].[0-9].[0-9]$ | cut -d'-' -f3); echo $VERSION
Last line command echos version as expected in any linux command line if curl
is installed, but during docker build no version is returned.
@TarunLalwani's comment led me to a way that saved me a lot of time.
It was all about my
resolv.conf
file which wasn't set properly and curl was not able to access the URL; but since I used somecut
andgrep
command ahead of that, I couldn't figure it out.I googled and I found out that I should set my desired configurations for
resolve.conf
, then executecurl
in oneRUN
command in order to be able to resolve the URL (described here).I have this
Dockerfile
now, which works fine: