This is a starting point for Rust solutions to the "Build Your Own Docker" Challenge.
In this challenge, you'll build a program that can pull an image from Docker Hub and execute commands in it. Along the way, we'll learn about chroot, kernel namespaces, the docker registry API and much more.
Note: If you're viewing this repo on GitHub, head over to codecrafters.io to signup for early access.
Usage
- Ensure you have Docker installed locally.
- Follow the details below ("Running your program locally") to run your Docker
implementation, which is implemented in
src/main.rs
. - Commit your changes and run
git push origin master
to submit your solution to CodeCrafters. Test output will be streamed to your terminal.
Running your program locally
Since you'll need to use linux-specific syscalls in this challenge, we'll run your code inside a docker container.
docker build -t my_docker . && docker run --cap-add="SYS_ADMIN" my_docker run some_image /usr/local/bin/docker-explorer echo hey
(The --cap-add="SYS_ADMIN"
flag is required to create
PID Namespaces)
To make this easier to type out, you could add a shell alias:
alias mydocker='docker build -t mydocker . && docker run --cap-add="SYS_ADMIN" mydocker'
You can then execute your program like this:
mydocker run ubuntu:latest /usr/local/bin/docker-explorer echo hey
Passing the first stage
CodeCrafters runs tests when you do a git push
. Make an empty commit and push
your solution to see the first stage fail.
git commit --allow-empty -m "Running tests"
git push origin master
Go to src/main.rs
and uncomment the implementation. Commit and push your
changes to pass the first stage:
git add .
git commit -m "pass the first stage"
git push origin master
Time to move on to the next stage!