[sage-support] Re: Help/Pointers on using docker with travis-ci

2019-07-30 Thread Simon King
Hi!

It seems that the following works:

- Start the container and wait until everything is functional, using
  docker's health check:
docker run --name=test -dit --health-cmd='sage -c "print(1)"' 
--health-interval='20s' --health-timeout='20s' --health-start-period='50s' 
sagemath/sagemath-dev:latest /bin/bash && until docker inspect --format "{{json 
.State.Health.Status }}" test | grep -m 1 -w "healthy"; do sleep 5; done

- Execute commands:
docker exec test command1
docker exec test command2
...

- Stop and remove the docker container.

Would you recommend a different solution?

Best regards,
Simon

On 2019-07-30, Simon King  wrote:
> Nathan,
>
> On 2019-07-29, Nathan Dunfield  wrote:
>> You can start a container and open a shell on it via:
>>
>> docker run -it image_name /bin/bash
>>
>> The container will keep running until you exit the shell, if not longer.  
>> You can open a shell on any running container via
>>
>> docker exec -it container_name /bin/bash
>
> It works to some extent: When I do
>   docker run -it --name bla sagemath/sagemath-dev:latest /bin/bash
> then (after waiting for some time because apparently the docker image
> does some compilation of Sage before doing anything else) I am indeed in
> a bash in docker - and stay there, interactively, which is not what I
> want.
>
> I.e., I need to leave with ctrl-p and ctrl-q, and then I can execute
> commands in that container (such as
>docker container exec bla sage -i meataxe
> )
>
> How can I start/run the container so that I don't need ctrl-p and
> ctrl-q? After all, I want to use the container with a script, not
> interactively. I tried the option "-dit", but then I don't know (and the
> script doesn't know) how long I need to wait until the preparatory steps
> of the container are done. Right after 
>   docker run -dit --name bla sagemath/sagemath-dev:latest /bin/bash
> the command
>   docker container exec bla sage -c "print('Hello')"
> fails, because "sage.all" is not there yet:
> Traceback (most recent call last):
>   File "/home/sage/sage/src/bin/sage-eval", line 4, in 
>   from sage.all import *
> ImportError: No module named sage.all
>
> The same command works after waiting long enough.
>
> Best regards,
> Simon
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/qhplk0%246b50%241%40blaine.gmane.org.


[sage-support] Re: Help/Pointers on using docker with travis-ci

2019-07-30 Thread Simon King
Nathan,

On 2019-07-29, Nathan Dunfield  wrote:
> You can start a container and open a shell on it via:
>
> docker run -it image_name /bin/bash
>
> The container will keep running until you exit the shell, if not longer.  
> You can open a shell on any running container via
>
> docker exec -it container_name /bin/bash

It works to some extent: When I do
  docker run -it --name bla sagemath/sagemath-dev:latest /bin/bash
then (after waiting for some time because apparently the docker image
does some compilation of Sage before doing anything else) I am indeed in
a bash in docker - and stay there, interactively, which is not what I
want.

I.e., I need to leave with ctrl-p and ctrl-q, and then I can execute
commands in that container (such as
   docker container exec bla sage -i meataxe
)

How can I start/run the container so that I don't need ctrl-p and
ctrl-q? After all, I want to use the container with a script, not
interactively. I tried the option "-dit", but then I don't know (and the
script doesn't know) how long I need to wait until the preparatory steps
of the container are done. Right after 
  docker run -dit --name bla sagemath/sagemath-dev:latest /bin/bash
the command
  docker container exec bla sage -c "print('Hello')"
fails, because "sage.all" is not there yet:
Traceback (most recent call last):
  File "/home/sage/sage/src/bin/sage-eval", line 4, in 
  from sage.all import *
ImportError: No module named sage.all

The same command works after waiting long enough.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/qhovbd%246m21%241%40blaine.gmane.org.


[sage-support] Re: Help/Pointers on using docker with travis-ci

2019-07-29 Thread Nathan Dunfield
Simon,

You can start a container and open a shell on it via:

docker run -it image_name /bin/bash

The container will keep running until you exit the shell, if not longer.  
You can open a shell on any running container via

docker exec -it container_name /bin/bash

Best,

Nathan

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/fb382921-6576-4789-be16-6012f9dfeea2%40googlegroups.com.