Skip to content

Commit 6b6bd49

Browse files
Merge pull request circleci#3972 from circleci/update-docker-install-example
Update the docker installation example
2 parents ce39922 + 680e1d2 commit 6b6bd49

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

jekyll/_cci2/building-docker-images.md

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,38 +67,35 @@ jobs:
6767
The example below shows how you can build and push a Docker image for our [demo docker project](https://github.com/CircleCI-Public/circleci-demo-docker):
6868

6969
```yaml
70-
version: 2
70+
version: 2.1
7171
jobs:
7272
build:
7373
docker:
74-
- image: golang:1.6.4-jessie # (1)
75-
working_directory: /go/src/github.com/CircleCI-Public/circleci-demo-docker
74+
- image: circleci/golang:1.13-alpine # (1)
7675
steps:
7776
- checkout
7877
# ... steps for building/testing app ...
7978
8079
- setup_remote_docker: # (2)
8180
docker_layer_caching: true # (3)
8281
83-
# use a primary image that already has Docker (recommended)
84-
# or install it during a build like we do here
85-
- run:
86-
name: Install Docker client
87-
command: |
88-
set -x
89-
VER="17.03.0-ce"
90-
curl -L -o /tmp/docker-$VER.tgz https://download.docker.com/linux/static/stable/x86_64/docker-$VER.tgz
91-
tar -xz -C /tmp -f /tmp/docker-$VER.tgz
92-
mv /tmp/docker/* /usr/bin
93-
9482
# build and push Docker image
9583
- run: |
9684
TAG=0.1.$CIRCLE_BUILD_NUM
97-
docker build -t CircleCI-Public/circleci-demo-docker:$TAG .
98-
docker login -u $DOCKER_USER -p $DOCKER_PASS # (4)
85+
docker build -t CircleCI-Public/circleci-demo-docker:$TAG .
86+
echo $DOCKER_PASS | docker login -u $DOCKER_USER --password-stdin # (4)
9987
docker push CircleCI-Public/circleci-demo-docker:$TAG
10088
```
10189

90+
If the primary container you are using doesn't already have the docker CLI installed, then [you will need to install it](https://docs.docker.com/install/#supported-platforms) somehow.
91+
92+
```yaml
93+
# Install via apk on alpine based images
94+
- run:
95+
name: Install Docker client
96+
command: apk add docker-cli
97+
```
98+
10299
Let’s break down what’s happening during this build’s execution:
103100

104101
1. All commands are executed in the [primary-container]({{ site.baseurl }}/2.0/glossary/#primary-container).
@@ -223,7 +220,7 @@ Then, the sample CircleCI `.circleci/config.yml` snippets below populate and bac
223220
keys:
224221
- v4-bundler-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
225222
- v4-bundler-cache-{{ arch }}-{{ .Branch }}
226-
- v4-bundler-cache-{{ arch }}
223+
- v4-bundler-cache-{{ arch }}
227224
- run:
228225
name: Restoring bundler cache into docker volumes
229226
command: |
@@ -245,7 +242,7 @@ Then, the sample CircleCI `.circleci/config.yml` snippets below populate and bac
245242
set -x
246243
docker-compose -f docker-compose.yml -f docker/circle-dockup.yml run --name $NAME $NAME backup
247244
docker cp $NAME:/backup/. $CACHE_PATH
248-
docker rm -f $NAME
245+
docker rm -f $NAME
249246
- save_cache:
250247
key: v4-bundler-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
251248
paths:

0 commit comments

Comments
 (0)