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.

Passing the first stage

The entry point for your Docker implementation is in src/main.rs. Study and uncomment the relevant code, and push your changes to pass the first stage:

git add .
git commit -m "pass the first stage"
git push origin master

That's all!

Setup for stages 2 & beyond

  1. Ensure you have Docker installed locally.
  2. Follow the details below ("Running your program locally") to run your Docker implementation, which is implemented in src/main.rs.
  3. 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

This command compiles your Rust project, so it might be slow the first time you run it. Subsequent runs will be fast.

Description
My code for CodeCrafter's "Build Your Own Docker" Challenge
Readme 64 KiB
Languages
Rust 87.9%
Dockerfile 8.9%
Shell 3.2%