If you get a message that the branch doesn't exist, add the `-b` flag (`git checkout -b dry-run-test`) so the
command both creates the branch and checks it out.
4. Use `make` to build a development environment image and run it in a container.
```none
$ make BIND_DIR=. shell
```
Using the instructions in the
`Dockerfile`, the build may need to download and / or configure source and other images. On first build this process may take between 5 - 15 minutes to create an image. The command returns informational messages as it runs. A
successful build returns a final message and opens a Bash shell into the
DEBU[0001] Registering POST, /networks/{id:.*}/connect
DEBU[0001] Registering POST, /networks/{id:.*}/disconnect
DEBU[0001] Registering DELETE, /networks/{id:.*}
INFO[0001] API listen on /var/run/docker.sock
DEBU[0003] containerd connection state change: READY
```
The `-D` flag starts the daemon in debug mode. The `&` starts it as a
background process. You'll find these options useful when debugging code
development. You will need to hit `return` in order to get back to your shell prompt.
> **Note**: The following command automates the `build`,
> `install`, and `run` steps above. Once the command below completes, hit `ctrl-z` to suspend the process, then run `bg 1` and hit `enter` to resume the daemon process in the background and get back to your shell prompt.
hello-world latest c54a2cc56cbb 3 months ago 1.85 kB
```
12. Open another terminal on your local host.
13. List the container running your development container.
```none
ubuntu@ubuntu1404:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a8b2885ab900 docker-dev:dry-run-test "hack/dind bash" 43 minutes ago Up 43 minutes hungry_payne
```
Notice that the tag on the container is marked with the `dry-run-test` branch name.
## Task 3. Make a code change
At this point, you have experienced the "Moby inception" technique. That is,
you have:
* forked and cloned the Moby Engine code repository
* created a feature branch for development
* created and started an Engine development container from your branch
* built a binary inside of your development container
* launched a `docker` daemon using your newly compiled binary
* called the `docker` client to run a `hello-world` container inside
your development container
Running the `make BIND_DIR=. shell` command mounted your local Docker repository source into
your Docker container.
> **Note**: Inspecting the `Dockerfile` shows a `COPY . /go/src/github.com/docker/docker` instruction, suggesting that dynamic code changes will _not_ be reflected in the container. However inspecting the `Makefile` shows that the current working directory _will_ be mounted via a `-v` volume mount.
When you start to develop code though, you'll
want to iterate code changes and builds inside the container. If you have
followed this guide exactly, you have a bash shell running a development
container.
Try a simple code change and see it reflected in your container. For this
example, you'll edit the help for the `attach` subcommand.
1. If you don't have one, open a terminal in your local host.
2. Make sure you are in your `moby-fork` repository.
```none
$ pwd
/Users/mary/go/src/github.com/moxiegirl/moby-fork
```
Your location should be different because, at least, your username is
different.
3. Open the `cmd/dockerd/docker.go` file.
4. Edit the command's help message.
For example, you can edit this line:
```go
Short: "A self-sufficient runtime for containers.",
```
And change it to this:
```go
Short: "A self-sufficient and really fun runtime for containers.",
```
5. Save and close the `cmd/dockerd/docker.go` file.
6. Go to your running docker development container shell.
7. Rebuild the binary by using the command `hack/make.sh binary` in the docker development container shell.
8. Stop Docker if it is running.
9. Copy the binaries to **/usr/bin** by entering the following commands in the docker development container shell.
```
hack/make.sh binary install-binary
```
10. To view your change, run the `dockerd --help` command in the docker development container shell.