Hello World#
Docker#
The easiest way to run ruby is with docker.
-
create directory:
1mkdir app -
Go into directory:
1cd app -
Create file
hello_world.rb:1 2 3 4 5
cat <<EOF > hello_world.rb #!/usr/bin/env ruby puts "Hello world" EOF -
Run docker:
1 2 3 4
docker run \ -ti --rm \ -v "`pwd`:/app" \ ruby:3.0 bash -
Go to
/app:1cd /app -
Run script:
1ruby ./hello_world.rb- Output:
1 2 3
root@479e74cd430a:/app# ruby ./hello_world.rb Hello world root@479e74cd430a:/app#
- Output: