Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chown command doesn't exist on docker toolbox #18

Closed
antogerva opened this issue Jan 21, 2018 · 20 comments
Closed

chown command doesn't exist on docker toolbox #18

antogerva opened this issue Jan 21, 2018 · 20 comments
Labels

Comments

@antogerva
Copy link

antogerva commented Jan 21, 2018

expected behaviour

The VNC viewer should start without issue on Docker Toolbox. The command scbw.play shouldn't required to work only with Docker for Windows(which require Hyper-V). The p

actual behaviour

scbw.play crash when performing while it chown doesn't exist on docker toolbox for window.

There should be a workaround instead of using:
COPY --chown=starcraft:users starcraft.zip $SC_DIR

I did a bit of search about the issue and found this. So maybe using usermod could fix this issue.
RUN usermod -u 1000 $SC_DIR

steps to reproduce

$ scbw.play --bots "krasi0" "CherryPi" --log_level=DEBUG --show_all
INFO checking docker version
DEBUG Using docker API version b"'1.26'\n"
INFO checking docker can run
INFO checking docker has network sc_net
DEBUG docker network id: b'2335fa0e8d4b\n'
INFO checking if there is local image starcraft:game
DEBUG docker image id: b''
INFO creating docker local image
INFO copying files from c:\python\python36_64\lib\site-packages\scbw/local_docker to C:\Users\<myuser>\AppData\Roaming/scbw/docker
INFO building local image starcraft:game, this may take a while...
Sending build context to Docker daemon  105.7MB
Step 1/13 : FROM starcraft:java
 ---> 9a75b8b8f224
Step 2/13 : MAINTAINER Michal Sustr <michal.sustr@aic.fel.cvut.cz>
 ---> Using cache
 ---> 0a0c8bc4abe9
Step 3/13 : USER starcraft
 ---> Using cache
 ---> ecedf151acef
Step 4/13 : WORKDIR $SC_DIR
 ---> Using cache
 ---> 6b99795e8a08
Step 5/13 : COPY --chown=starcraft:users starcraft.zip $SC_DIR
Unknown flag: chown
ERROR An error occurred while trying to build local image
Traceback (most recent call last):
  File "c:\python\python36_64\lib\site-packages\scbw\docker.py", line 123, in create_local_image
    raise DockerException()
scbw.error.DockerException

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\python\python36_64\lib\site-packages\scbw\cli.py", line 134, in main
    game_result = run_game(args)
  File "c:\python\python36_64\lib\site-packages\scbw\game.py", line 88, in run_game
    check_docker_requirements(args.docker_image)
  File "c:\python\python36_64\lib\site-packages\scbw\docker.py", line 162, in check_docker_requirements
    check_docker_has_local_image(image) or create_local_image()
  File "c:\python\python36_64\lib\site-packages\scbw\docker.py", line 128, in create_local_image
    raise DockerException(f"An error occurred while trying to build local image")
scbw.error.DockerException: An error occurred while trying to build local image

operating system

windows 10
note: i tried on ubuntu without issue

docker version

output of command docker version:
$ docker version
Client:
Version: 17.07.0-ce
API version: 1.26 (downgraded from 1.31)
Go version: go1.8.3
Git commit: 8784753
Built: Tue Aug 29 17:41:05 2017
OS/Arch: windows/amd64

Server:
Version: 1.13.1
API version: 1.26 (minimum version 1.12)
Go version: go1.7.5
Git commit: 092cba3
Built: Wed Feb 8 08:47:51 2017
OS/Arch: linux/amd64
Experimental: false

scbw version

output of command scbw.play -v
0.2a19

@michalsustr
Copy link
Collaborator

Can you please try following?

FROM starcraft:java
MAINTAINER Michal Sustr <michal.sustr@aic.fel.cvut.cz>

#####################################################################
USER starcraft
WORKDIR $SC_DIR

# Get Starcraft game from ICCUP
COPY starcraft.zip /tmp/starcraft.zip
COPY default* /tmp/

RUN unzip /tmp/starcraft.zip -d /tmp/starcraft \
    && rm -rf /tmp/starcraft/characters/* /tmp/starcraft/maps/* \
    && chown starcraft:users -R /tmp/starcraft \
    && cp /tmp/default* /tmp/starcraft/characters \
    && chown starcraft:users -R /tmp/starcraft/characters

USER root
RUN rm /tmp/starcraft.zip \
    && mv /tmp/starcraft/* $SC_DIR/

USER starcraft

RUN mkdir -m 775 $BWAPI_DATA_DIR $BWAPI_DATA_BWTA_DIR $BWAPI_DATA_BWTA2_DIR
RUN mkdir -m 755 $BOT_DIR $BOT_DATA_AI_DIR $BOT_DATA_READ_DIR
RUN mkdir -m 777 $BOT_DATA_WRITE_DIR
VOLUME $BWAPI_DATA_BWTA_DIR $BWAPI_DATA_BWTA2_DIR $MAP_DIR $BOT_DIR $BOT_DATA_WRITE_DIR

RUN echo "umask 0027" >> /home/starcraft/.bashrc

WORKDIR $APP_DIR

I tested on ubuntu and it is equivalent.

You will need to docker rmi starcraft:game and put dockerfile into .scbw/docker/game.dockerfile (or APP_DATA on win)

@antogerva
Copy link
Author

antogerva commented Jan 23, 2018

Ok, I did as you said. Note: the game.dockerfile is overwritten by <python_folder>/Lib/site-packages/scbw/local_docker/game.dockerfile, which I edited as intended.

Now, it seem the script is stuck there:

scbw.play --bots "krasi0" "CherryPi" --log_level=DEBUG --show_all
INFO checking docker version
DEBUG Using docker API version b"'1.26'\n"
INFO checking docker can run
INFO checking docker has network sc_net
DEBUG docker network id: b'2335fa0e8d4b\n'
INFO checking if there is local image starcraft:game
DEBUG docker image id: b'593a7dded75d\n'
DEBUG checking bot in C:\Users\MyUser\AppData\Roaming/scbw/bots/krasi0
DEBUG found bot in C:\Users\MyUser\AppData\Roaming/scbw/bots/krasi0
DEBUG checking bot in C:\Users\MyUser\AppData\Roaming/scbw/bots/CherryPi
DEBUG found bot in C:\Users\MyUser\AppData\Roaming/scbw/bots/CherryPi
DEBUG ['docker', 'run', '-d', '--rm', '--privileged', '--name', 'GAME_F0A900EA_0_krasi0', '--volume', 'C:\\Users\\MyUser\\AppData\\Roaming/scbw/logs:/app/logs:rw', '--volume', 'C:\\Users\\MyUser\\AppData\\Roaming/scbw/bots:/app/bots:ro', '--volume', 'C:\\Users\\MyUser\\AppData\\Roaming/scbw/maps:/app/sc/maps:rw', '--volume', 'C:\\Users\\MyUser\\AppData\\Roaming/scbw/bwapi-data/BWTA:/app/sc/bwapi-data/BWTA:rw', '--volume', 'C:\\Users\\MyUser\\AppData\\Roaming/scbw/bwapi-data/BWTA2:/app/sc/bwapi-data/BWTA2:rw', '--net', 'sc_net', '-p', '5900:5900', '--volume', 'C:\\Users\\MyUser\\AppData\\Roaming/scbw/bots/krasi0/write/GAME_F0A900EA_0:/app/sc/bwapi-data/write:rw', '-e', 'PLAYER_NAME=krasi0', '-e', 'PLAYER_RACE=T', '-e', 'NTH_PLAYER=0', '-e', 'NUM_PLAYERS=2', '-e', 'GAME_NAME=GAME_F0A900EA', '-e', 'MAP_NAME=/app/sc/maps/sscai/(2)Benzene.scx', '-e', 'GAME_TYPE=FREE_FOR_ALL', '-e', 'SPEED_OVERRIDE=0', '-e', 'BOT_NAME=krasi0', '-e', 'BOT_FILE=krasi0AIClient.exe', 'starcraft:game', '/app/play_bot.sh', '--headful']
docker: Error response from daemon: invalid bind mount spec "C:\\Users\\MyUser\\AppData\\Roaming/scbw/bots:/app/bots:ro": invalid volume specification: 'C:\Users\MyUser\AppData\Roaming/scbw/bots:/app/bots:ro'.
See 'docker run --help'.
ERROR could not launch BotPlayer:krasi0:T in container GAME_F0A900EA_0_krasi0
Traceback (most recent call last):
  File "c:\python\python36_64\lib\site-packages\scbw\cli.py", line 134, in main
    game_result = run_game(args)
  File "c:\python\python36_64\lib\site-packages\scbw\game.py", line 150, in run_game
    launch_game(players, launch_params, args.show_all, args.read_overwrite, wait_callback)
  File "c:\python\python36_64\lib\site-packages\scbw\docker.py", line 307, in launch_game
    launch_image(player, nth_player=i, num_players=len(players), **launch_params)
  File "c:\python\python36_64\lib\site-packages\scbw\docker.py", line 288, in launch_image
    f"could not launch {player} in container {game_name}_{nth_player}_{player.name}")
scbw.error.DockerException: could not launch BotPlayer:krasi0:T in container GAME_F0A900EA_0_krasi0

Maybe the docker commands doesn't deal with regular "/" on the Windows platform? (similar issue are using //)

edit: Well, look like this is the same issue as #15, so this can be closed.

@michalsustr
Copy link
Collaborator

Can you run just the docker run command?

docker run  --rm --privileged --name GAME_F0A900EA_0_krasi0 --volume "C:\\Users\\MyUser\\AppData\\Roaming\\scbw\\logs:/app/logs:rw" --volume "C:\\Users\\MyUser\\AppData\\Roaming\\scbw\\bots:/app/bots:ro" --volume "C:\\Users\\MyUser\\AppData\\Roaming\\scbw\\maps:/app/sc/maps:rw" --volume "C:\\Users\\MyUser\\AppData\\Roaming\\scbw\\bwapi-data\\BWTA:/app/sc/bwapi-data/BWTA:rw" --volume "C:\\Users\\MyUser\\AppData\\Roaming\\scbw\\bwapi-data\\BWTA2:/app/sc/bwapi-data/BWTA2:rw" --volume "C:\\Users\\MyUser\\AppData\\Roaming\\scbw\\bots\\krasi0\\write\\GAME_F0A900EA_0:/app/sc/bwapi-data/write:rw" -e PLAYER_NAME=krasi0 -e PLAYER_RACE=T -e NTH_PLAYER=0 -e NUM_PLAYERS=2 -e GAME_NAME=GAME_F0A900EA -e MAP_NAME="/app/sc/maps/sscai/(2)Benzene.scx" -e GAME_TYPE=FREE_FOR_ALL -e SPEED_OVERRIDE=0 -e BOT_NAME=krasi0 -e BOT_FILE=krasi0AIClient.exe starcraft:game /app/play_bot.sh --net sc_net -p 5900:5900 --headful

@michalsustr
Copy link
Collaborator

I edited the / vs \

@antogerva
Copy link
Author

antogerva commented Jan 23, 2018

Your command didn't work(...Error response from daemon: invalid bind mount spec...), but this helped to figure something with this info. Basicaly the volume should be simply mounted using //c/ as root. So, I got following result:

$ docker run  --rm --privileged --name GAME_F0A900EA_0_krasi0 --volume "//c/Users/MyUser/AppData/Roaming/scbw/logs:/app/logs:rw" --volume "//c/Users/MyUser/AppData/Roaming/scbw/bots:/app/bots:ro" --volume "//c/Us
ers/MyUser/AppData/Roaming/scbw/maps:/app/sc/maps:rw" --volume "//c/Users/MyUser/AppData/Roaming/scbw/bwapi-data/BWTA:/app/sc/bwapi-data/BWTA:rw" --volume "//c/Users/MyUser/AppData/Roaming/scbw/bwapi-data/BWTA2:/a
pp/sc/bwapi-data/BWTA2:rw" --volume "//c/Users/MyUser/AppData/Roaming/scbw/bots/krasi0/write/GAME_F0A900EA_0:/app/sc/bwapi-data/write:rw" -e PLAYER_NAME=krasi0 -e PLAYER_RACE=T -e NTH_PLAYER=0 -e NUM_PLAYERS=2 -
e GAME_NAME=GAME_F0A900EA -e MAP_NAME="/app/sc/maps/sscai/(2)Benzene.scx" -e GAME_TYPE=FREE_FOR_ALL -e SPEED_OVERRIDE=0 -e BOT_NAME=krasi0 -e BOT_FILE=krasi0AIClient.exe starcraft:game /app/play_bot.sh --net sc
_net -p 5900:5900 --headful
+ '[' --net == --headful ']'
+ IS_HEADFUL=0
+ LOG_BASENAME=GAME_F0A900EA_0_krasi0
+ LOG_GAME=/app/logs/GAME_F0A900EA_0_krasi0_game.log
+ LOG_BOT=/app/logs/GAME_F0A900EA_0_krasi0_bot.log
+ BOT_TYPE=exe
++ date +%Y-%m-%d
+ DATE=2018-01-23
+ REPLAY_FILE=maps/replays/2018-01-23_GAME_F0A900EA_0.rep
+ . play_common.sh
+ check_bot_requirements
+ '[' '!' -d /app/bots/krasi0 ']'
+ '[' '!' -f /app/bots/krasi0/AI/krasi0AIClient.exe ']'
+ '[' '!' -f /app/bots/krasi0/BWAPI.dll ']'
+ '[' exe '!=' jar ']'
+ '[' exe '!=' exe ']'
+ cp -r /app/bots/krasi0/AI/. /app/sc/bwapi-data/AI
+ cp -r /app/bots/krasi0/read/. /app/sc/bwapi-data/read
+ cp -r /app/bwapi/bot/. /app/sc/bwapi-data
+ cp /app/bots/krasi0/BWAPI.dll /app/sc/bwapi-data
+ BOT_EXECUTABLE=/app/sc/bwapi-data/AI/krasi0AIClient.exe
+ '[' exe == dll ']'
+ prepare_bwapi NULL
+ PLAYER_DLL=NULL
+ echo 'Preparing bwapi.ini'
+ BWAPI_INI=/app/sc/bwapi-data/bwapi.ini
Preparing bwapi.ini
++ sed s:/app/sc/maps:maps:g
++ echo '/app/sc/maps/sscai/(2)Benzene.scx'
+ MAP='maps/sscai/(2)Benzene.scx'
++ fully_qualified_race_name T
++ SHORT=T
++ '[' T == T ']'
++ echo Terran
+ RACE=Terran
+ sed -i 's:^ai = NULL:ai = NULL:g' /app/sc/bwapi-data/bwapi.ini
+ sed -i 's:^character_name = :character_name = krasi0:g' /app/sc/bwapi-data/bwapi.ini
+ sed -i 's:^race = :race = Terran:g' /app/sc/bwapi-data/bwapi.ini
+ sed -i 's:^game_type = :game_type = FREE_FOR_ALL:g' /app/sc/bwapi-data/bwapi.ini
+ sed -i 's:^save_replay = :save_replay = maps/replays/2018-01-23_GAME_F0A900EA_0.rep:g' /app/sc/bwapi-data/bwapi.ini
+ sed -i 's:^wait_for_min_players = :wait_for_min_players = 2:g' /app/sc/bwapi-data/bwapi.ini
+ sed -i 's:^speed_override = :speed_override = 0:g' /app/sc/bwapi-data/bwapi.ini
+ '[' 0 == 1 ']'
+ '[' 0 == 0 ']'
+ sed -i 's:map = :map = maps/sscai/(2)Benzene.scx:g' /app/sc/bwapi-data/bwapi.ini
+ sed -i 's:^game = :game = GAME_F0A900EA:g' /app/sc/bwapi-data/bwapi.ini
+ . hook_update_bwapi_ini.sh
++ echo 'hook: update bwapi ini'
+ cat /app/sc/bwapi-data/bwapi.ini
+ prepare_character
+ mv /app/sc/characters/default.spc /app/sc/characters/krasi0.spc
hook: update bwapi ini
[ai]
ai = NULL
ai_dbg = NULL
tournament =

[auto_menu]
auto_menu = LAN
character_name = krasi0
pause_dbg = OFF
lan_mode = Local Area Network (UDP)
auto_restart = OFF
map = maps/sscai/(2)Benzene.scx
game = GAME_F0A900EA
mapiteration = RANDOM
race = Terran
enemy_count = 1
enemy_race = Protoss
enemy_race_1 = Default
enemy_race_2 = Default
enemy_race_3 = Default
enemy_race_4 = Default
enemy_race_5 = Default
enemy_race_6 = Default
enemy_race_7 = Default
game_type = FREE_FOR_ALL
game_type_extra =
save_replay = maps/replays/2018-01-23_GAME_F0A900EA_0.rep
wait_for_min_players = 2
wait_for_max_players = 8
wait_for_time = 60000

[config]
holiday = OFF
shared_memory = OFF
console_attach_on_startup = FALSE
console_alloc_on_startup = FALSE
console_attach_auto = TRUE
console_alloc_auto = TRUE

[window]
windowed = OFF
left = 0
top  = 0
width  = 640
height = 480

[starcraft]
sound = OFF
screenshots = gif
speed_override =
drop_players = ON
+ mv /app/sc/characters/default.mpc /app/sc/characters/krasi0.mpc
+ start_gui
+ echo 'Starting X, savings logs to ' /app/logs/GAME_F0A900EA_0_krasi0_xvfb.log
+ sleep 1
+ Xvfb :0 -auth /home/starcraft/.Xauthority -screen 0 640x480x24
Starting X, savings logs to  /app/logs/GAME_F0A900EA_0_krasi0_xvfb.log
+ echo 'Starting VNC server' /app/logs/GAME_F0A900EA_0_krasi0_xvnc.log
+ sleep 1
+ x11vnc -forever -nopw -display :0
Starting VNC server /app/logs/GAME_F0A900EA_0_krasi0_xvnc.log
+ start_bot
+ . hook_before_bot_start.sh
++ echo 'hook: before bot start'
+ echo 'Starting bot krasi0AIClient.exe, savings logs to /app/logs/GAME_F0A900EA_0_krasi0_bot.log'
+ echo ------------------------------------------
hook: before bot start
Starting bot krasi0AIClient.exe, savings logs to /app/logs/GAME_F0A900EA_0_krasi0_bot.log
++ date +%Y-%m-%dT%H:%M:%S%z
+ echo 'Started bot at' 2018-01-23T09:26:52+0000
+ . hook_after_bot_start.sh
++ echo 'hook: after bot start'
+ sleep 3
hook: after bot start
+ pushd /app/sc
+ '[' exe == jar ']'
+ '[' exe == exe ']'
+ wine /app/sc/bwapi-data/AI/krasi0AIClient.exe
/app/sc /app
+ start_game --net sc_net -p 5900:5900 --headful
+ . hook_before_game_start.sh
++ echo 'hook: before game start'
+ '[' -f /app/sc/maps/replays/LastReplay.rep ']'
hook: before game start
+ echo 'Starting game, savings logs to /app/logs/GAME_F0A900EA_0_krasi0_game.log'
+ echo ------------------------------------------
Starting game, savings logs to /app/logs/GAME_F0A900EA_0_krasi0_game.log
++ date +%Y-%m-%dT%H:%M:%S%z
+ echo 'Started game at' 2018-01-23T09:26:55+0000
+ . hook_after_game_start.sh
++ echo 'hook: after game start'
+ sleep 10
+ launch_game --net sc_net -p 5900:5900 --headful
hook: after game start
+ '[' -z '' ']'
+ ./play_detect_game_finished.sh maps/replays/2018-01-23_GAME_F0A900EA_0.rep
./play_detect_game_finished.sh: line 11: : No such file or directory
./play_detect_game_finished.sh: line 15: : No such file or directory

Now I guess ./play_detect_game_finished.sh should be bundled with the rest of the script?

@michalsustr
Copy link
Collaborator

michalsustr commented Jan 23, 2018

It could be because I made some further changes to game finished detection :) Maybe retry with master?

So all I have to do for docker toolbox on windows is to replace C:\ with //c/ ?

Doesn't that break docker for windows?

@kant2002
Copy link
Contributor

I could test both commands tomorrow morning, when I will be in the office (GMT+6). I run Docker for Windows so I would like to verify that C: replacement with //c/ will work for me.

@kant2002
Copy link
Contributor

On Docker for Windows //c/ replacement works too.

@michalsustr
Copy link
Collaborator

Does it matter if it is forward/backward slash?

@kant2002
Copy link
Contributor

/ slashes work very well on Windows

@michalsustr
Copy link
Collaborator

So this should be enough?

def xoscmounts(host_mount):
    """
    Cross OS compatible mount dirs
    """
    return re.sub("^([a-zA-Z])\:", "//\\1", host_mount)

and then

"--volume", f"{xoscmounts(log_dir)}:{LOG_DIR}:rw",

@kant2002
Copy link
Contributor

This should works for me, but we should wait @antogerva until it test without //c/ since this is not just usage of the / instead of \ on Windows. I earlier have similar issues with Docker Toolbox where IIRC just / trick does not work for me (since this is first what I test) and I have to use path starting with //c/.

@michalsustr
Copy link
Collaborator

michalsustr commented Jan 24, 2018

The code snippet I've posted does only the //c/ replacement, but for any one-letter drive :) maybe it's not needed though, since APP_DATA should always be in C:\ hmmm

@antogerva
Copy link
Author

antogerva commented Jan 24, 2018

@michalsustr Sound good, I guess the one-letter replacement is how it should be in case of weird symlink to an another drive, etc.

I attempted to build these docker images locally on docker-toolbox and see if I could test, but I got stuck there:

 git clone https://github.com/Games-and-Simulations/sc-docker.git && cd sc-docker/docker
 ./build_images.sh
...
Step 22/29 : COPY --chown=starcraft:users dlls/* $WINEPREFIX/drive_c/windows/system32/
Unknown flag: chown

So, I guess I should wait for an update on Docker Hub for further tests.

@antogerva
Copy link
Author

antogerva commented Jan 25, 2018

I saw there's an update on DockerHub. Now I get the following output.

Also, I realized I could just modify <python-install>/Lib/site-packages/scbw/docker.py, I went ahead and fixed the path issue:

...
import re
def xoscmounts(host_mount):
    """
    Cross OS compatible mount dirs
    """
    return re.sub("^([a-zA-Z])\:", "//\\1", host_mount)
...
    cmd = ["docker", "run",

           "-d",
           "--rm",
           "--privileged",

           "--name", f"{game_name}_{nth_player}_{player.name.replace(' ', '_')}",

           "--volume", f"{xoscmounts(log_dir)}:{LOG_DIR}:rw",
           #"--volume", f"{log_dir}:{LOG_DIR}:rw",
           "--volume", f"{xoscmounts(log_dir)}:{LOG_DIR}:rw",           
           #"--volume", f"{bot_dir}:{BOT_DIR}:ro",
           "--volume", f"{xoscmounts(bot_dir)}:{BOT_DIR}:ro",           
           #"--volume", f"{map_dir}:{MAP_DIR}:rw",
           "--volume", f"{xoscmounts(map_dir)}:{MAP_DIR}:rw",           
           
           #"--volume", f"{bwapi_data_bwta_dir}:{BWAPI_DATA_BWTA_DIR}:rw",
           "--volume", f"{xoscmounts(bwapi_data_bwta_dir)}:{BWAPI_DATA_BWTA_DIR}:rw",
           #"--volume", f"{bwapi_data_bwta2_dir}:{BWAPI_DATA_BWTA2_DIR}:rw",
           "--volume", f"{xoscmounts(bwapi_data_bwta2_dir)}:{BWAPI_DATA_BWTA2_DIR}:rw",
           ]
...
    if isinstance(player, BotPlayer):
        bot_data_write_dir = f"{player.base_dir}/write/{game_name}_{nth_player}"
        os.makedirs(bot_data_write_dir, mode=0o777, exist_ok=True)  # todo: proper mode
        #cmd += ["--volume", f"{bot_data_write_dir}:{BOT_DATA_WRITE_DIR}:rw"]
        cmd += ["--volume", f"{xoscmounts(bot_data_write_dir)}:{BOT_DATA_WRITE_DIR}:rw"]
...

Now, I get the following output:

$ scbw.play --bots "krasi0" "CherryPi" --log_level=DEBUG --show_all
INFO checking docker version
DEBUG Using docker API version b"'1.26'\n"
INFO checking docker can run
INFO checking docker has network sc_net
DEBUG docker network id: b'2335fa0e8d4b\n'
INFO checking if there is local image starcraft:game
DEBUG docker image id: b'5e9fd88d1616\n'
DEBUG checking bot in C:\Users\MyUser\AppData\Roaming/scbw/bots/krasi0
DEBUG found bot in C:\Users\MyUser\AppData\Roaming/scbw/bots/krasi0
DEBUG checking bot in C:\Users\MyUser\AppData\Roaming/scbw/bots/CherryPi
DEBUG found bot in C:\Users\MyUser\AppData\Roaming/scbw/bots/CherryPi
DEBUG ['docker', 'run', '-d', '--rm', '--privileged', '--name', 'GAME_33884C27_0_krasi0', '--volume', '//C\\Users\\MyUser\\AppData\\Roaming/scbw/logs:/app/logs:rw', '--volume', '//C\\Users\\MyUser\\AppData\\Roaming/scbw/logs:/app/logs:rw', '--volume', '//C\\Users\\MyUser\\AppData\\Roaming/scbw/bots:/app/bots:ro', '--volume', '//C\\Users\\MyUser\\AppData\\Roaming/scbw/maps:/app/sc/maps:rw', '--volume', '//C\\Users\\MyUser\\AppData\\Roaming/scbw/bwapi-data/BWTA:/app/sc/bwapi-data/BWTA:rw', '--volume', '//C\\Users\\MyUser\\AppData\\Roaming/scbw/bwapi-data/BWTA2:/app/sc/bwapi-data/BWTA2:rw', '--net', 'sc_net', '-p', '5900:5900', '--volume', '//C\\Users\\MyUser\\AppData\\Roaming/scbw/bots/krasi0/write/GAME_33884C27_0:/app/sc/bwapi-data/write:rw', '-e', 'PLAYER_NAME=krasi0', '-e', 'PLAYER_RACE=T', '-e', 'NTH_PLAYER=0', '-e', 'NUM_PLAYERS=2', '-e', 'GAME_NAME=GAME_33884C27', '-e', 'MAP_NAME=/app/sc/maps/sscai/(2)Benzene.scx', '-e', 'GAME_TYPE=FREE_FOR_ALL', '-e', 'SPEED_OVERRIDE=0', '-e', 'BOT_NAME=krasi0', '-e', 'BOT_FILE=krasi0AIClient.exe', 'starcraft:game', '/app/play_bot.sh', '--headful']
INFO launched BotPlayer:krasi0:T in container GAME_33884C27_0_krasi0
DEBUG ['docker', 'run', '-d', '--rm', '--privileged', '--name', 'GAME_33884C27_1_CherryPi', '--volume', '//C\\Users\\MyUser\\AppData\\Roaming/scbw/logs:/app/logs:rw', '--volume', '//C\\Users\\MyUser\\AppData\\Roaming/scbw/logs:/app/logs:rw', '--volume', '//C\\Users\\MyUser\\AppData\\Roaming/scbw/bots:/app/bots:ro', '--volume', '//C\\Users\\MyUser\\AppData\\Roaming/scbw/maps:/app/sc/maps:rw', '--volume', '//C\\Users\\MyUser\\AppData\\Roaming/scbw/bwapi-data/BWTA:/app/sc/bwapi-data/BWTA:rw', '--volume', '//C\\Users\\MyUser\\AppData\\Roaming/scbw/bwapi-data/BWTA2:/app/sc/bwapi-data/BWTA2:rw', '--net', 'sc_net', '-p', '5901:5900', '--volume', '//C\\Users\\MyUser\\AppData\\Roaming/scbw/bots/CherryPi/write/GAME_33884C27_1:/app/sc/bwapi-data/write:rw', '-e', 'PLAYER_NAME=CherryPi', '-e', 'PLAYER_RACE=Z', '-e', 'NTH_PLAYER=1', '-e', 'NUM_PLAYERS=2', '-e', 'GAME_NAME=GAME_33884C27', '-e', 'MAP_NAME=/app/sc/maps/sscai/(2)Benzene.scx', '-e', 'GAME_TYPE=FREE_FOR_ALL', '-e', 'SPEED_OVERRIDE=0', '-e', 'BOT_NAME=CherryPi', '-e', 'BOT_FILE=BWEnv.dll', 'starcraft:game', '/app/play_bot.sh', '--headful']
INFO launched BotPlayer:CherryPi:Z in container GAME_33884C27_1_CherryPi
INFO Checking if game has launched properly...
DEBUG running containers: []
ERROR Some containers exited prematurely, please check logs
Traceback (most recent call last):
  File "c:\python\python36_64\lib\site-packages\scbw\cli.py", line 134, in main
    game_result = run_game(args)
  File "c:\python\python36_64\lib\site-packages\scbw\game.py", line 150, in run_game
    launch_game(players, launch_params, args.show_all, args.read_overwrite, wait_callback)
  File "c:\python\python36_64\lib\site-packages\scbw\docker.py", line 326, in launch_game
    raise DockerException("Some containers exited prematurely, please check logs")
scbw.error.DockerException: Some containers exited prematurely, please check logs

Look like the container failed to launch. I'm not sure if I'm missing something...

edit: I mean, can I get additionnal log on what might have failed?

@kant2002
Copy link
Contributor

@antogerva The container could failed to launch (but more specifically immediately close after launch) if there already exist replay files. Since you probably try launch games multiple times, GAME_33884C27_0_krasi0 and GAME_33884C27_1_CherryPi replays probably already here.

@antogerva
Copy link
Author

antogerva commented Jan 26, 2018

Ok, I did more tests and turn out on docker-toolbox, the drive-letter need to be lower case. I also removed completly the backslash. I fixed this with the following code:

import re
def xoscmounts(host_mount):
    """
    Cross OS compatible mount dirs
    """
    callback = lambda pat: pat.group(1).lower()
    x_host_mount = re.sub(r"^([a-zA-Z])\:", callback, host_mount)
    x_host_mount = re.sub(r"^([a-z])", "//\\1", x_host_mount)
    x_host_mount = re.sub(r"\\", "/", x_host_mount)  
    return x_host_mount

Now, I believe there's one last issue. Look like loopback connection is disabled on the VNC server?

$ scbw.play --bots "krasi0" "CherryPi" --log_level=DEBUG --show_all
...
DEBUG checking bot in C:\Users\MyUser\AppData\Roaming/scbw/bots/krasi0
DEBUG found bot in C:\Users\MyUser\AppData\Roaming/scbw/bots/krasi0
DEBUG checking bot in C:\Users\MyUser\AppData\Roaming/scbw/bots/CherryPi
DEBUG found bot in C:\Users\MyUser\AppData\Roaming/scbw/bots/CherryPi
launching...
DEBUG ['docker', 'run', '-d', '--rm', '--privileged', '--name', 'GAME_E5F68BC0_0_krasi0', '--volume', '//c/Users/MyUser/AppData/Roaming/scbw/logs:/app/logs:rw', '--volume', '//c/Users/MyUser/AppData/Roaming/scbw/logs:/app/logs:rw', '--volume', '//c/Users/MyUser/AppData/Roaming/scbw/bots:/app/bots:ro', '--volume', '//c/Users/MyUser/AppData/Roaming/scbw/maps:/app/sc/maps:rw', '--volume', '//c/Users/MyUser/AppData/Roaming/scbw/bwapi-data/BWTA:/app/sc/bwapi-data/BWTA:rw', '--volume', '//c/Users/MyUser/AppData/Roaming/scbw/bwapi-data/BWTA2:/app/sc/bwapi-data/BWTA2:rw', '--net', 'sc_net', '-p', '5900:5900', '--volume', '//c/Users/MyUser/AppData/Roaming/scbw/bots/krasi0/write/GAME_E5F68BC0_0:/app/sc/bwapi-data/write:rw', '-e', 'PLAYER_NAME=krasi0', '-e', 'PLAYER_RACE=T', '-e', 'NTH_PLAYER=0', '-e', 'NUM_PLAYERS=2', '-e', 'GAME_NAME=GAME_E5F68BC0', '-e', 'MAP_NAME=/app/sc/maps/sscai/(2)Benzene.scx', '-e', 'GAME_TYPE=FREE_FOR_ALL', '-e', 'SPEED_OVERRIDE=0', '-e', 'BOT_NAME=krasi0', '-e', 'BOT_FILE=krasi0AIClient.exe', 'starcraft:game', '/app/play_bot.sh', '--headful']
INFO launched BotPlayer:krasi0:T in container GAME_E5F68BC0_0_krasi0
launching...
DEBUG ['docker', 'run', '-d', '--rm', '--privileged', '--name', 'GAME_E5F68BC0_1_CherryPi', '--volume', '//c/Users/MyUser/AppData/Roaming/scbw/logs:/app/logs:rw', '--volume', '//c/Users/MyUser/AppData/Roaming/scbw/logs:/app/logs:rw', '--volume', '//c/Users/MyUser/AppData/Roaming/scbw/bots:/app/bots:ro', '--volume', '//c/Users/MyUser/AppData/Roaming/scbw/maps:/app/sc/maps:rw', '--volume', '//c/Users/MyUser/AppData/Roaming/scbw/bwapi-data/BWTA:/app/sc/bwapi-data/BWTA:rw', '--volume', '//c/Users/MyUser/AppData/Roaming/scbw/bwapi-data/BWTA2:/app/sc/bwapi-data/BWTA2:rw', '--net', 'sc_net', '-p', '5901:5900', '--volume', '//c/Users/MyUser/AppData/Roaming/scbw/bots/CherryPi/write/GAME_E5F68BC0_1:/app/sc/bwapi-data/write:rw', '-e', 'PLAYER_NAME=CherryPi', '-e', 'PLAYER_RACE=Z', '-e', 'NTH_PLAYER=1', '-e', 'NUM_PLAYERS=2', '-e', 'GAME_NAME=GAME_E5F68BC0', '-e', 'MAP_NAME=/app/sc/maps/sscai/(2)Benzene.scx', '-e', 'GAME_TYPE=FREE_FOR_ALL', '-e', 'SPEED_OVERRIDE=0', '-e', 'BOT_NAME=CherryPi', '-e', 'BOT_FILE=BWEnv.dll', 'starcraft:game', '/app/play_bot.sh', '--headful']
INFO launched BotPlayer:CherryPi:Z in container GAME_E5F68BC0_1_CherryPi
INFO Checking if game has launched properly...
docker ps -f "name=GAME_4C678DA1" -q
DEBUG running containers: ['822431b49397', '3d22db2e6369']
INFO Launching vnc viewer for BotPlayer:krasi0:T on port 5900
INFO Launching vnc viewer for BotPlayer:CherryPi:Z on port 5901
INFO
In headful mode, you must specify and start the game manually.
Select the map, wait for bots to join the game and then start the game.
INFO Waiting until game is finished...
docker ps -f "name=GAME_4C678DA1" -q
DEBUG running containers: ['822431b49397', '3d22db2e6369']
docker ps -f "name=GAME_4C678DA1" -q
DEBUG running containers: ['822431b49397', '3d22db2e6369']
docker ps -f "name=GAME_4C678DA1" -q
DEBUG running containers: ['822431b49397', '3d22db2e6369']
...

So, I look up what's going on and added -loop to this line with the following command:

docker run -it starcraft:game /bin/bash #login into a container
#edit play_common.sh
docker commit -m "fix stuff" -a "antogerva" <container-id> starcraft:game #saving as new image

The image update went well. Yet, it seem adding -loop to x11vnc didn't help.

@antogerva
Copy link
Author

antogerva commented Jan 26, 2018

Ok, I actually managed to get this working on Docker-Toolbox (screenshot: 1, 2 )
Get the docker ip:
$ docker-machine ip
Then launch the container and then connect with your VNC client!

@michalsustr
Copy link
Collaborator

Great, I'll use the drive letter function you posted.

Why is there different IP? I thought it should be on the local net:
https://github.com/Games-and-Simulations/sc-docker/blob/master/scbw/docker.py#L63

@antogerva
Copy link
Author

antogerva commented Jan 26, 2018

@michalsustr Look like the only way to get localhost to work on docker-toolbox is to directly modify some settings in virtualbox about port fowarding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants