Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Crystal in Docker on Linux

  • Docker Crystal
  • Install Docker
  • Create a file called crystal with the following content:
docker run --rm -it -w/opt -v$(pwd):/opt crystallang/crystal crystal $*
  • Make it executable by running chmod +x crystal
  • Run ./crystal examples/intro/hello_world.cr

Alternative:

Start docker container:

docker run --rm -it -w/opt -v$(pwd):/opt --name crystal -d crystallang/crystal tail -f /opt/Dockerfile

Execute in the running container:

docker exec crystal crystal examples/intro/hello_world.cr

Later you can stop the container:

docker -t0 stop crystal