On Thu, Feb 8, 2018 at 3:53 PM, Dan Pungă <dan.pu...@gmail.com> wrote:
> I guess it does have to do with your Docker version. > I have: > > Client: > Version: 17.12.0-ce > API version: 1.35 > Go version: go1.9.2 > Git commit: c97c6d6 > Built: Wed Dec 27 20:11:19 2017 > OS/Arch: linux/amd64 > > Server: > Engine: > Version: 17.12.0-ce > API version: 1.35 (minimum version 1.12) > Go version: go1.9.2 > Git commit: c97c6d6 > Built: Wed Dec 27 20:09:53 2017 > OS/Arch: linux/amd64 > Experimental: false > > Yes, found this in the reference manual: https://docs.docker.com/v1.13/ > engine/reference/builder/#/from > "*As such, a valid* *Dockerfile** must have **FROM* *as its first > instruction*" > > while for 17.12, it appears they have relaxed this requirement. > Based on that, I would expect whatever behavior you're observing is driven by the docker daemon version on your openshift cluster nodes. > > > > > On 08.02.2018 17:19, Ben Parees wrote: > > > > On Wed, Feb 7, 2018 at 10:30 AM, Dan Pungă <dan.pu...@gmail.com> wrote: > >> Thanks for your answers Ben! >> >> And yes, apparently, I've skimmed through the docs with this bit, which >> explains why the devs didn't have to implement handling ARGs before the >> FROM instructions in Dockerfiles... :) So I'll just have to point to >> different images in the yaml config. >> >> Regarding the first reply and example, the ARG instruction has scope >> within Dockerfile. So, in your second example, the OS_name is available >> just for the FROM instruction, after which it losses scope. You have to >> redefine it to use it after the FROM. However the --build-arg overwrites >> all references: >> >> ARG OS_name="centos" >> ARG OS_version="7" >> >> FROM $OS_name:$OS_version >> >> ARG OS_version="foobar" >> >> RUN echo $OS_version >> RUN exit 1 >> ============= >> >> $*docker build .* ##so with default values for ARG taken into >> consideration >> > > This fails for me. And not because of the exit 1(which is intentional so > we can see the echo output): > > $ cat Dockerfile > ARG OS_name="centos" > ARG OS_version="7" > > FROM $OS_name:$OS_version > > ARG OS_version="foobar" > > RUN echo $OS_version > RUN exit 1 > > $ docker build . > Sending build context to Docker daemon 3.072 kB > > > *Step 1/6 : ARG OS_name="centos" Please provide a source image with `from` > prior to commit * > > > $ docker version > Client: > Version: 1.13.1 > API version: 1.26 > Package version: docker-1.13.1-44.git584d391.fc27.x86_64 > Go version: go1.9.1 > Git commit: caba767-unsupported > Built: Thu Nov 23 21:17:26 2017 > OS/Arch: linux/amd64 > > Server: > Version: 1.13.1 > API version: 1.26 (minimum version 1.12) > Package version: docker-1.13.1-44.git584d391.fc27.x86_64 > Go version: go1.9.1 > Git commit: caba767-unsupported > Built: Thu Nov 23 21:17:26 2017 > OS/Arch: linux/amd64 > Experimental: false > > > Sending build context to Docker daemon 2.048kB >> Step 1/6 : ARG OS_name="centos" >> Step 2/6 : ARG OS_version="7" >> Step 3/6 : FROM $OS_name:$OS_version >> ---> ff426288ea90 >> Step 4/6 : ARG OS_version="foobar" >> ---> Running in b5ac67ae7fc5 >> Removing intermediate container b5ac67ae7fc5 >> ---> 753bc14d3a4b >> Step 5/6 : RUN echo $OS_version >> ---> Running in 15c759544a4b >> *foobar* >> Removing intermediate container 15c759544a4b >> ---> 0e1d41c4ddda >> Step 6/6 : RUN exit 1 >> ---> Running in 9dfc7176d6b9 >> The command '/bin/sh -c exit 1' returned a non-zero code: 1 >> >> ============= >> >> $ *docker build -t tst --build-arg OS_version=6.9 .* ##the OS_version >> passed as cmd option is taken into account in all scopes >> Sending build context to Docker daemon 2.048kB >> Step 1/6 : ARG OS_name="centos" >> Step 2/6 : ARG OS_version="7" >> Step 3/6 : FROM $OS_name:$OS_version >> 6.9: Pulling from library/centos >> 993c50d47469: Pull complete >> Digest: sha256:5cf988fbf143af398f879bd626ee677da3f8d229049b721079092 >> 8a02613ab26 >> Status: Downloaded newer image for *centos:6.9* >> ---> fca4c61d0fa7 >> Step 4/6 : ARG OS_version="foobar" >> ---> Running in d58a5321aa65 >> Removing intermediate container d58a5321aa65 >> ---> d345fcd2fe46 >> Step 5/6 : RUN echo $OS_version >> ---> Running in a408a3cd16ee >> *6.9* >> Removing intermediate container a408a3cd16ee >> ---> 2d8e5ee7cc03 >> Step 6/6 : RUN exit 1 >> ---> Running in 61b8011e52dd >> The command '/bin/sh -c exit 1' returned a non-zero code: 1 >> >> >> >> On 07.02.2018 16:50, Ben Parees wrote: >> >> btw, openshift will happily substitute your FROM statement w/ an image >> referenced by your BuildConfig, so if that's your goal, perhaps that is a >> way to accomplish it. >> >> https://docs.openshift.org/latest/dev_guide/builds/build_str >> ategies.html#docker-strategy-from >> >> On Wed, Feb 7, 2018 at 9:48 AM, Ben Parees <bpar...@redhat.com> wrote: >> >>> >>> >>> On Wed, Feb 7, 2018 at 6:59 AM, Dan Pungă <dan.pu...@gmail.com> wrote: >>> >>>> Hello all! >>>> I've recently discovered and join this mailing list; hope I'm in the >>>> right place. >>>> I'm new to the OShift ecosystem, currently trying to develop a >>>> configuration to containerize some apps. I'm using minishift local cluster >>>> on a Ubuntu 16.04 machine (details below). >>>> >>>> I want to write a parametrized yaml template to configure the build >>>> process for my layers (those with a dockerStrategy) with using(or, better >>>> said connecting to ) the arguments defined in my Dockerfiles. I have found >>>> that OShift doesn't support ARG instructions prior to the FROM one when it >>>> reads the Dockerfile. >>>> >>> >>> you sure even docker supports that? It's not working for me: >>> >>> this works (just using an arg generically and echoing it out): >>> >>> $ cat Dockerfile >>> FROM centos >>> ARG OS_name="centos" >>> >>> RUN echo $OS_name >>> RUN exit 1 >>> >>> $ docker build --build-arg OS_name=centos . >>> Sending build context to Docker daemon 2.048 kB >>> Step 1/4 : FROM centos >>> ---> ff426288ea90 >>> Step 2/4 : ARG OS_name="centos" >>> ---> Using cache >>> ---> 59f6494cb002 >>> Step 3/4 : RUN echo $OS_name >>> ---> Running in 092e2600490e >>> >>> *centos * ---> 8a3f570a033c >>> Removing intermediate container 092e2600490e >>> Step 4/4 : RUN exit 1 >>> ---> Running in 543cefc9eab8 >>> The command '/bin/sh -c exit 1' returned a non-zero code: 1 >>> >>> This does not (not even referencing the arg in my FROM, just putting the >>> ARG before FROM): >>> $ cat Dockerfile >>> ARG OS_name="centos" >>> FROM centos >>> >>> RUN echo $OS_name >>> RUN exit 1 >>> >>> $ docker build --build-arg OS_name=centos . >>> Sending build context to Docker daemon 2.048 kB >>> Step 1/4 : ARG OS_name="centos" >>> Please provide a source image with `from` prior to commit >>> >>> >>> >>> So i think this is a docker restriction, not an openshift one. >>> >>> >>> So, even if a docker build would run successfully with something like: >>>> >>>> ARG OS_name="centos" >>>> ARG OS_version="6.8" >>>> >>>> FROM ${OS_name}:${OS_version} >>>> #....rest of Dockerfile instructions... >>>> >>>> if I try to define in my yaml config >>>> strategy: >>>> dockerStrategy: >>>> buildArgs: >>>> - name: OS_name >>>> value: "7" >>>> >>>> the build process does not work. >>>> >>>> Has anyone else come across this issue and how did you get around it? >>>> What I'm trying to achieve is single configuration structure for multiple >>>> versions, so I wouldn't have to write separate Docker configs for different >>>> app versions. For example building a Java JRE layer on top of different OSs >>>> with one file. >>>> Thank you, >>>> Dan >>>> >>>> PS: The closest thread regarding this issue that I've found in the >>>> archive is https://lists.openshift.redhat.com/openshift-archives/users/ >>>> 2017-January/msg00104.html >>>> >>>> Running env details: >>>> >>>> oc version >>>> oc v3.6.0+c4dd4cf >>>> kubernetes v1.6.1+5115d708d7 >>>> features: Basic-Auth GSSAPI Kerberos SPNEGO >>>> >>>> Server https://192.168.99.100:8443 >>>> openshift v3.6.0+c4dd4cf >>>> kubernetes v1.6.1+5115d708d7 >>>> ========= >>>> >>>> docker@minishift:~$ docker version >>>> Client: >>>> Version: 1.12.3 >>>> API version: 1.24 >>>> Go version: go1.6.3 >>>> Git commit: 6b644ec >>>> Built: Wed Oct 26 23:26:11 2016 >>>> OS/Arch: linux/amd64 >>>> >>>> Server: >>>> Version: 1.12.3 >>>> API version: 1.24 >>>> Go version: go1.6.3 >>>> Git commit: 6b644ec >>>> Built: Wed Oct 26 23:26:11 2016 >>>> OS/Arch: linux/amd64 >>>> >>>> >>>> _______________________________________________ >>>> users mailing list >>>> users@lists.openshift.redhat.com >>>> http://lists.openshift.redhat.com/openshiftmm/listinfo/users >>>> >>>> >>> >>> >>> -- >>> Ben Parees | OpenShift >>> >>> >> >> >> -- >> Ben Parees | OpenShift >> >> >> > > > -- > Ben Parees | OpenShift > > > -- Ben Parees | OpenShift
_______________________________________________ users mailing list users@lists.openshift.redhat.com http://lists.openshift.redhat.com/openshiftmm/listinfo/users