Skip to content

Commit 689eca4

Browse files
ehussmark-i-m
authored andcommitted
Update docs on using Docker images.
1 parent 88f57a5 commit 689eca4

File tree

1 file changed

+44
-6
lines changed

1 file changed

+44
-6
lines changed

src/tests/intro.md

+44-6
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,54 @@ Rust's [platform tiers]).
136136
## Testing with Docker images
137137

138138
The Rust tree includes [Docker] image definitions for the platforms used on
139-
Azure Pipelines in [src/ci/docker]. The script [src/ci/docker/run.sh] is used to build
139+
Azure Pipelines in [`src/ci/docker`]. The script [`src/ci/docker/run.sh`] is used to build
140140
the Docker image, run it, build Rust within the image, and run the tests.
141141

142-
> TODO: What is a typical workflow for testing/debugging on a platform that
143-
> you don't have easy access to? Do people build Docker images and enter them
144-
> to test things out?
142+
You can run these images on your local development machine. This can be
143+
helpful to test environments different from your local system. First you will
144+
need to install Docker on a Linux, Windows, or macOS system (typically Linux
145+
will be much faster than Windows or macOS because the later use virtual
146+
machines to emulate a Linux environment). To enter interactive mode which will
147+
start a bash shell in the container, run `src/ci/docker/run.sh --dev <IMAGE>`
148+
where `<IMAGE>` is one of the directory names in `src/ci/docker` (for example
149+
`x86_64-gnu` is a fairly standard Ubuntu environment).
150+
151+
The docker script will mount your local rust source tree in read-only mode,
152+
and an `obj` directory in read-write mode. All of the compiler artifacts will
153+
be stored in the `obj` directory. The shell will start out in the `obj`
154+
directory. From there, you can run `../src/ci/run.sh` which will run the build
155+
as defined by the image.
156+
157+
Alternatively, you can run individual commands to do specific tasks. For
158+
example, you can run `python3 ../x.py test src/test/ui` to just run UI tests.
159+
Note that there is some configuration in the [`src/ci/run.sh`] script that you
160+
may need to recreate. Particularly, set `submodules = false` in your
161+
`config.toml` so that it doesn't attempt to modify the read-only directory.
162+
163+
Some additional notes about using the Docker images:
164+
165+
- Some of the std tests require IPv6 support. Docker on Linux seems to have it
166+
disabled by default. Run the commands in [`enable-docker-ipv6.sh`] to enable
167+
IPv6 before creating the container. This only needs to be done once.
168+
- The container will be deleted automatically when you exit the shell, however
169+
the build artifacts persist in the `obj` directory. If you are switching
170+
between different Docker images, the artifacts from previous environments
171+
stored in the `obj` directory may confuse the build system. Sometimes you
172+
will need to delete parts or all of the `obj` directory before building
173+
inside the container.
174+
- The container is bare-bones, with only a minimal set of packages. You may
175+
want to install some things like `apt install less vim`.
176+
- You can open multiple shells in the container. First you need the container
177+
name (a short hash), which is displayed in the shell prompt, or you can run
178+
`docker container ls` outside of the container to list the available
179+
containers. With the container name, run `docker exec -it <CONTAINER>
180+
/bin/bash` where `<CONTAINER>` is the container name like `4ba195e95cef`.
145181

146182
[Docker]: https://www.docker.com/
147-
[src/ci/docker]: https://github.com/rust-lang/rust/tree/master/src/ci/docker
148-
[src/ci/docker/run.sh]: https://github.com/rust-lang/rust/blob/master/src/ci/docker/run.sh
183+
[`src/ci/docker`]: https://github.com/rust-lang/rust/tree/master/src/ci/docker
184+
[`src/ci/docker/run.sh`]: https://github.com/rust-lang/rust/blob/master/src/ci/docker/run.sh
185+
[`src/ci/run.sh`]: https://github.com/rust-lang/rust/blob/master/src/ci/run.sh
186+
[`enable-docker-ipv6.sh`]: https://github.com/rust-lang/rust/blob/master/src/ci/scripts/enable-docker-ipv6.sh
149187

150188
## Running tests on a remote machine
151189

0 commit comments

Comments
 (0)