Build docker images - what's the recommended way

Sample in https://circleci.com/docs/2.0/building-docker-images/, it mentioned

      # use a primary image that already has Docker (recommended)
      ??? Then where are the sample codes?

But how? Why not give the sample codes directly and let us to guess?

After that, it gives sample to install docker each time, that’s weird document.

version: 2
jobs:
  build:
    docker:
      - image: golang:1.6.4-jessie   # (1)
    working_directory: /go/src/github.com/CircleCI-Public/circleci-demo-docker
    steps:
      - checkout
      # ... steps for building/testing app ...

      - setup_remote_docker:   # (2)
          docker_layer_caching: true # (3)

      # use a primary image that already has Docker (recommended)
      # or install it during a build like we do here
      - run:
          name: Install Docker client
          command: |
            set -x
            VER="17.03.0-ce"
            curl -L -o /tmp/docker-$VER.tgz https://download.docker.com/linux/static/stable/x86_64/docker-$VER.tgz
            tar -xz -C /tmp -f /tmp/docker-$VER.tgz
            mv /tmp/docker/* /usr/bin

It perhaps is worth pointing out that the documentation authors were not setting out to confuse you, ozbillwang. Writing documentation is really tricky to get right - if there is too much detail, then useful stuff gets lost in the noise for more experienced developers.

What the instructions are saying is that you can swap - image: golang:1.6.4-jessie for an image where Docker is already installed. Take a look on Docker Hub for docker images - in general, they would do fine.

My unpopular opinion, that I offer here a fair bit, is that CI is not easy, and it requires a solid familiarity with the (Linux) console. If you’re new to Docker, then spend a bit of time working with Docker locally - even a few days of tutorials will help a great deal.

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