Connection between docker container and script - docker

I'm starting my script and open connection with docker swarm, in docker swarm i open selenium.
Question
how execute all my code from one script in one container
cause when i start get some page,
and after try get_elements by xpath
first container open page,
second (with empty page) trying get elements by xpath

Related

Docker compose start without detach

From terminal 1 there are multiple docker compose services running, from time to time I need to run another container (for testing purposes) from terminal 2. I should see the output of the testing container from terminal 2, but this is not possible when using the start command because the output will be detached.
Basically I need the same behaviour as the run command without creating more containers but the start command has no options.
How can I do that?

Can we replace an image with docker-compose while container is running

I am working at a micro-service application and there are multiple services. I am using docker-compose to run instances of different micro services. We create an image for every micro service. If I change the code of a micro-service, I use 'docker-compose down' then changing the version of updated micro service and then use 'docker-compose up'. I think, there should be a way to update the image at run time without using 'docker-compose down' and 'docker-compose up'.
Is there and way to replace image of running container with docker-compose?
You can skip docker-compose down. The docker-compose up command will recreate the container if the image has been built or pulled since it was last started. See this answer for more details and an example of this in action.
You cannot hot swap the image from within a running container. That's equivalent to replacing the root hard drive while a Linux OS is running. It would break things, particularly anything with an open file handle.

Problem running steps inside custom docker container using GitHub Action

I'm using GH actions for testing a GO application, I created on docker-hub a custom image (guerra1994/go-mqtt-docker) with docker(DiD)/go/mosquitto and in action file I just used with label container:. (my expectation is it runs all steps inside the container)
In one test of the application, there is a test that checks docker ps -a command, I expect that return empty result but it returns one container is present, that container is mine like container runs by the runner of actions see "host" container or maybe it creates as "brother" container and not as "child".
I don't really understand what is happening... Some can help me?
Another workaround is to create an executable docker image that runs all command to execute tests directly in ENTRYPOINT
The probel is -v /var/run/docker.sock:/var/run/docker.sock that allows your container to see other in your host machine

Launch container from webpage

I have looked at sonata project demo page: http://demo.sonata-project.org
There is something wonderfull on this page: They can start a container from a webpage.
How can we do that ?
What i want to do too is to wait the container ready before redirecting to it.
And how can they automaticly delete the container after 10 minutes ?
Thanks
You can create a frontend API over docker commands as per your customization , in backend docker commands are only running so when you press start button it will run docker run command to start container and so on.. for removing the container you can easily filter docker containers on basis of timestamps : https://docs.docker.com/engine/reference/commandline/system_prune/#filtering.

Viewing startup logs of docker

How can we view container startup logs of docker. (ie: when container is starting up viz boot.log in Jboss for eg. as in what all events are kicking up while container is coming up.)
As of now I can view any event in logs when container comes up, but I cannot find any mechanism to view logs when container is starting up.
Any idea?
Ok, I got a way to do that.
1) First do "docker events&" where you want to run you container.
2) Then run your container like:
docker run -d .... (Full command)
It will generate a Hex Id for container (look out at the end).
(container=f1b76ae5a75a1443c01181de46767gbb03621167d019f5d26d3e5131d9158843511a69, name=bridge, type=bridge)
3) Now go in another window and see the logs:
docker logs (from previous step)
This is especially useful if your container is not coming up properly.

Resources