Skip to content

Commit af2e02b

Browse files
committed
editorial changes and add ssh remote docker
1 parent 6b6bd49 commit af2e02b

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

jekyll/_cci2/building-docker-images.md

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ categories: [configuring-jobs]
77
order: 55
88
---
99

10-
This document explains how to build Docker images for deploying elsewhere or for further testing and how to start services in remote docker containers in the following sections:
10+
This document explains how to build Docker images for deployment elsewhere or further testing, and how to start services in a remote docker environment.
1111

1212
* TOC
1313
{:toc}
@@ -27,12 +27,12 @@ jobs:
2727
2828
When `setup_remote_docker` executes, a remote environment will be created, and your current [primary container]({{ site.baseurl }}/2.0/glossary/#primary-container) will be configured to use it. Then, any docker-related commands you use will be safely executed in this new environment.
2929

30-
**Note:** The use of the `setup_remote_docker` key is reserved for configs in which your primary executor _is_ a docker container. If your executor is `machine` or `macos` (and you want to use docker commands in your config) you do not need to use the `setup_remote_docker` key.
30+
**Note:** The use of the `setup_remote_docker` key is reserved for configs in which your primary executor _is_ a docker container. If your executor is `machine` or `macos` (and you want to use docker commands in your config) you do **not** need to use the `setup_remote_docker` key.
3131

3232
### Specifications
3333
{:.no_toc}
3434

35-
The Remote Docker Environment has the following technical specifications:
35+
The Remote Docker Environment has the following technical specifications (for CircleCI Server installations, contact the systems administrator for specifications):
3636

3737
CPUs | Processor | RAM | HD
3838
-----|---------------------------|-----|------
@@ -42,7 +42,7 @@ CPUs | Processor | RAM | HD
4242
### Example
4343
{:.no_toc}
4444

45-
The example below shows how you can build a Docker image using `machine` with the default image:
45+
The example below shows how you can build a Docker image using the `machine` executor with the default image - this does not require the use of remote Docker:
4646

4747
```yaml
4848
version: 2
@@ -64,30 +64,30 @@ jobs:
6464
- run: docker push company/app:$CIRCLE_BRANCH
6565
```
6666

67-
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):
67+
The example below shows how you can build and deploy a Docker image for our [demo docker project](https://github.com/CircleCI-Public/circleci-demo-docker) usind the Docker executor, with remote Docker:
6868

69-
```yaml
69+
{% highlight yaml linenos %}
7070
version: 2.1
7171
jobs:
7272
build:
7373
docker:
74-
- image: circleci/golang:1.13-alpine # (1)
74+
- image: circleci/golang:1.13-alpine
7575
steps:
7676
- checkout
7777
# ... steps for building/testing app ...
7878

79-
- setup_remote_docker: # (2)
80-
docker_layer_caching: true # (3)
79+
- setup_remote_docker:
80+
docker_layer_caching: true
8181

8282
# build and push Docker image
8383
- run: |
8484
TAG=0.1.$CIRCLE_BUILD_NUM
8585
docker build -t CircleCI-Public/circleci-demo-docker:$TAG .
86-
echo $DOCKER_PASS | docker login -u $DOCKER_USER --password-stdin # (4)
86+
echo $DOCKER_PASS | docker login -u $DOCKER_USER --password-stdin
8787
docker push CircleCI-Public/circleci-demo-docker:$TAG
88-
```
88+
{% endhighlight %}
8989

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.
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).
9191

9292
```yaml
9393
# Install via apk on alpine based images
@@ -98,10 +98,10 @@ If the primary container you are using doesn't already have the docker CLI insta
9898

9999
Let’s break down what’s happening during this build’s execution:
100100

101-
1. All commands are executed in the [primary-container]({{ site.baseurl }}/2.0/glossary/#primary-container).
102-
2. Once `setup_remote_docker` is called, a new remote environment is created, and your primary container is configured to use it. All docker-related commands are also executed in your primary container, but building/pushing images and running containers happens in the remote Docker Engine.
103-
3. We enable [Docker Layer Caching]({{ site.baseurl }}/2.0/glossary/#docker-layer-caching) (DLC) here to speed up image building (**note:** the option `docker_layer_caching: true` is available on [Performance and Custom plans](https://circleci.com/pricing/), not the Free plan. DLC is available on CircleCI Server installations).
104-
4. We use project environment variables to store credentials for Docker Hub.
101+
1. All commands are executed in the [primary-container]({{ site.baseurl }}/2.0/glossary/#primary-container). (line 5)
102+
2. Once `setup_remote_docker` is called, a new remote environment is created, and your primary container is configured to use it. All docker-related commands are also executed in your primary container, but building/pushing images and running containers happens in the remote Docker Engine. (line 10)
103+
3. We enable [Docker Layer Caching]({{ site.baseurl }}/2.0/glossary/#docker-layer-caching) (DLC) here to speed up image building (**note:** the option `docker_layer_caching: true` is available on [Performance and Custom plans](https://circleci.com/pricing/), not the Free plan. DLC is available on CircleCI Server installations). (line 11)
104+
4. We use project environment variables to store credentials for Docker Hub. (line 17)
105105

106106
## Docker Version
107107

@@ -137,10 +137,10 @@ CircleCI supports multiple versions of Docker and defaults to using `17.09.0-ce`
137137
Consult the [Stable releases](https://download.docker.com/linux/static/stable/x86_64/) or [Edge releases](https://download.docker.com/linux/static/edge/x86_64/) for the full list of supported versions.
138138
--->
139139

140-
**Note:** The `version` key is not currently supported on CircleCI installed in your private cloud or datacenter. Contact your system administrator for information about the Docker version installed in your remote Docker environment.
140+
**Note:** The `version` key is not currently supported on CircleCI Server installations. Contact your system administrator for information about the Docker version installed in your remote Docker environment.
141141

142142
## Separation of Environments
143-
The job and [remote docker]({{ site.baseurl }}/2.0/glossary/#remote-docker) run in separate environments. Therefore, Docker containers cannot directly communicate with the containers running in remote docker.
143+
The job and [remote docker]({{ site.baseurl }}/2.0/glossary/#remote-docker) run in separate environments. Therefore, Docker containers specified to run your jobs cannot directly communicate with containers running in remote docker.
144144

145145
### Accessing Services
146146
{:.no_toc}
@@ -250,6 +250,14 @@ Then, the sample CircleCI `.circleci/config.yml` snippets below populate and bac
250250
```
251251
{% endraw %}
252252

253+
### Accessing the Remote Docker environment
254+
255+
When a remote Docker environment is spun up, an SSH alias is created for you so you can SSH into the remote Docker virtual machine. This may be helpful for debugging your builds, or modifying the Docker or VM filesystem configuration. To SSH into the remote Docker VM, run the following within your project configuration job steps, or during a SSH rerun:
256+
257+
```
258+
ssh remote-docker
259+
```
260+
253261
**Note:** The example shown above provides a way for you to utilize volume mounts since they don't work in the `docker` executor. An alternative to this approach is to use the `machine` executor where volume mounts do work.
254262

255263
Thanks to ryansch for contributing this example.

0 commit comments

Comments
 (0)