Create a ruby container on windows with docker and run the ruby script you edited on windows.
$docker-compose up-d
)version: '3' services: rubyapp: image:ruby:2.5-alpine container_name —myruby
C:/home/docker/myapp/ |-- docker-compose.yml `-- ruby `-- app `-- test.rb $ echo "putsTime.now" > ruby/app/test.rb
Run the following command
# Missing error with path on Windows $ winty docker run-v "C:\home\docker\myapp\ruby\app": /root ruby: 2.5 -alpine ruby ruby/app/test.rb ruby: No such file or directory -- ruby/app/test.rb (LoadError) # Error specifying path on container $ winty docker run-v "C:\home\docker\myapp\ruby\app": /root ruby: 2.5 -alpine ruby/root/test.rb ruby: No such file or directory -- C:/Program Files/Git/root/test.rb (LoadError) # -e option allows you to do it $ winty docker run-v "C:\home\docker\myapp\ruby\app": /root ruby:2.5-alpine ruby-e "puts Time.now" 2018-12-17 05:47:23 +0000
I would appreciate it if you could let me know if the method of specifying the command is bad or not possible in the first place.
Thank you for your cooperation.
If you just want to run ruby, you don't need to create docker-compose.yml.
The above command shows
I think it is an error because workdir is not configured.
$docker run --workdir=/app --volume="C:\home\docker\myapp\ruby\app":/app ruby:2.5-alpine ruby test.rb
Also, if you cannot find the file,
$docker run --workdir=/app --volume="C:\home\docker\myapp\ruby\app":/appruby:2.5-alpine/bin/sh
You may also want to go find the mounted file in
© 2024 OneMinuteCode. All rights reserved.