Multi-stage docker


#1

With the latest beta docker installed (17.05.0-ce-rc3) after the setup of the remote docker engine on CircleCi 2.0, I get a parsing error like this whenever I try to build a multi-stage image:

Error parsing reference: "node:7.9.0-alpine AS base" is not a valid repository/tag: invalid reference format

My multi-stage docker image builds with the edge version of docker mac. Am I missing some other thing that I should be installing?


#2

Can you share the top of your config?


#3

Try running docker version. Both client and server must be 17.05 to use the new multi-stage builds.

AFAIK, there is no way to manually upgrade the remote Docker host in CircleCI 2.0.


#4

You can update the Docker engine if you use the machine executor.

version: 2
jobs:
  build:
    working_directory: ~/circle2test
    machine: true
    steps:
      - checkout
      - run: docker version
      - run: sudo service docker stop
      - run: curl -fsSL https://get.docker.com/ | sudo sh
      - run: docker version

See https://circleci.com/gh/StefanScherer/circle2test/4

But you can also wait until Docker 17.05 is officially installed in the Docker executor as well.


#5

I’d also like to use 17.05.0 for multi stage, waiting hopefully :slight_smile:


#6

:thumbsup: works for me.


#7

Is there a timetable of when 17.05.0 support would be in? Also need this feature and doing this all from a VM is very slow.


#8

I would be interested to know this too! Having a way to use a more recent version in the docker executor (or to specify one, even) would be perfect for us.

I would understandably rather not rewrite the whole circle.yml to use the machine executor instead.


#9

I’m also trying to do multi-stage docker builds in circle. How do we upgrade the remote docker version? Currently I see see 17.03 for the server and would like to get 17.06.

Thanks!

+ docker version
Client:
 Version:      17.06.0-ce
 API version:  1.26 (downgraded from 1.30)
 Go version:   go1.8.3
 Git commit:   02c1d87
 Built:        Fri Jun 23 21:15:15 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.03.0-ce
 API version:  1.26 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   60ccb22
 Built:        Thu Feb 23 10:57:47 2017
 OS/Arch:      linux/amd64
 Experimental: false

#10

We’re planning to release updated Docker version for the machine executor in the next week or two. You’ll be able to choose the default or specify a version from a selection of recent releases.


#11

What about updating the Docker version on the docker executor? I’m trying to do a multistage build using the following config, but the server version is 17.03.0-ce.

version: 2
jobs:
  build:
    docker:
      - image: docker:17.06-git
    working_directory: ~/app
    steps:
      - checkout
      - setup_remote_docker:
          reusable: true
      - run:
          name: Validate the docker version
          command: docker version
      ....
$ #!/bin/sh -eo pipefail
docker version

Client:
 Version:      17.06.0-ce
 API version:  1.26 (downgraded from 1.30)
 Go version:   go1.8.3
 Git commit:   02c1d87
 Built:        Fri Jun 23 21:15:15 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.03.0-ce
 API version:  1.26 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   60ccb22
 Built:        Thu Feb 23 10:57:47 2017
 OS/Arch:      linux/amd64
 Experimental: false

#12

The version of Docker used for standard docker builds is not exposed. It’s only used for pulling and running images, so the version is not critical.

In the example posted, you’re using setup_remote_docker and the version of Server that is reported there will be upgraded to allow you to do multi-stage builds. We haven’t upgraded yet, but it’ll be available soon.


#13

Thanks. Do I need to use setup_remote_docker if I’m using the docker image as my base? The documentation made it sound like it was required. Thanks!


#14

setup_remote_docker is only needed if you’re wanting to do things like build Docker containers or run docker-compose. For most normal builds, you don’t need it and you’ll get faster startup times without it.


#15

You can get a newer Docker version with machine by using the “edge” machine image: https://circleci.com/docs/2.0/configuration-reference/#machine

jobs:
  build:
    machine:
      image: circleci/classic:edge

Instead if you are using setup_remote_docker you can use this: https://circleci.com/docs/2.0/building-docker-images/#docker-version

      - setup_remote_docker:
          version: 17.05.0-ce

#16

that’s awesome! looking forward to it.


#17

Ricardo’s solution above (Multi-stage docker) works already. Do let us know if you try it out.


#18

Works great, thanks!


#19

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.