I have a virtual Machine for Docker on my freenas system. On this rancheros docker machine I installed the openproject docker container.
With the freenas boot, there will automatically start the docker machine in which I installed the openproject docker container.
But how can I start the openproject container inside automatically?
Assuming that you have configured Docker to start automatically when your VM boots, you can tell Docker to start containers automatically by setting an always restart policy on them:
docker run --restart=unless-stopped ...
You can also set a restart policy on an existing container:
docker update --restart=unless-stopped mycontainer
With a restart policy of unless-stopped, Docker will "restart the container regardless of the exit status, including on daemon startup, except if the container was put into a stopped state before the Docker daemon was stopped".
Related
If I run this command: docker-compose up --detach:
It just returns the default information about Docker:
Builds, (re)creates, starts, and attaches to containers for a service.
Unless they are already running, this command also starts any linked services.
The `docker-compose up` command aggregates the output of each container. When
the command exits, all containers are stopped. Running `docker-compose up -d`
starts the containers in the background and leaves them running.
If there are existing containers for a service, and the service's configuration
or image was changed after the container's creation, `docker-compose up` picks
up the changes by stopping and recreating the containers (preserving mounted
volumes). To prevent Compose from picking up changes, use the `--no-recreate`
flag.
How can I get it to run?
I've tried docker-compose up -d, which returns:
ERROR: Couldn't connect to Docker daemon - you might need to run docker-machine start default`.
Are you sure the Docker daemon is running? Try running this:
sudo systemctl start docker
Or on older systems:
sudo service docker start
You can also use environment variables to debug what is the problem with the Docker daemon:
eval "$(docker-machine env default)"
then
docker-compose --verbose up -d
It seems Docker daemon is not running. Start it by this command (temporarily until the next reboot):
systemctl start docker
If on older OSes:
service docker start
Then run your command docker-compose up -d. If it worked, now you should enable docker so that when you reboot the OS, the daemon starts automatically:
systemctl enable docker
If on older OSes:
service docker enable
I have accessed a Remote Machine (call it , RM) through SSH (from my host). And I am running a docker image inside RM via my SSH session. Both are Ubuntu 16.04 based.
There are some processes running inside this docker container, so I can't exit the container.
So,how do I detach this ssh session from my host, so that those processes inside the docker would still run unaffected.
I am doing this, because I have to restart my host machine for some purpose.
PS:
In this link Correct way to detach from a container without stopping it, it's not running the docker container via SSH session. So two scenarios are different.
First, you have to start your Docker container in daemon (non-interactive) mode, using -d argument and dropping -it. Don't forget to name your container for further usage with --name foo option.
After container is started, you can control it using docker exec -it foo sh-or-whatever. If your ssh session will terminate, container will continue running. However, you docker exec session will be over.
I'm running a gitlab/gitlab-ce container on docker. Then , inside it, i want to run a gitlab-runner service, by providing docker as runner. And every single command that i run (e.g docker ps, docker container ..), i get this error:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is
the docker daemon running
P.s: i've tried service docker restart, reinstal docker and gitlab-runner.
By default it is not possible to run docker-in-docker (as a security measure).
You can run your Gitlab container in privileged mode, mount the socket (-v /var/run/docker.sock://var/run/docker.sock) and try again.
Also, there is a docker-in-docker image that has been modified for docker-in-docker usage. You can read up on it here and create your own custom gitlab/gitlab-ce image.
In both cases, the end result will be the same as docker-in-docker isn't really docker-in-docker but lets your manage the hosts docker-engine from within a docker container. So just running the Gitlab-ci-runner docker image on the same host has the same result and is a lot easier.
By default the docker container running gitlab does not have access to your docker daemon on your host. The docker client uses a socket connection to communicate to the docker daemon. This socket is not available in your container.
You can use a docker volume to make the socket of your host available in the container:
docker run -v /var/run/docker.sock:/var/run/docker.sock gitlab/gitlab-ce
Afterwards you will be able to use the docker client in your container to communicate with the docker daemon on the host.
Run docker container on a Linux system. From docker ps can see all the processes.
After restart the system and run docker ps can't see some containers, but use docker ps -a can see them. Is the container still running?
If you don't set the option --restart=always when run the docker container, these containers will not be started automatically, after you restart the system.
Restart policies (–restart)
always - Always restart the container regardless of the exit status. When you specify always, the Docker daemon will try to restart the container indefinitely. The container will also always start on daemon startup, regardless of the current state of the container.
Refer: docker run - Restart policies (–restart)
I was having a network issue, so I restarted my local machine, which also aborted my docker default VM. So I ran the below command to restart my virtualbox instance docker-machine restart default.
I previously had built containers on default, but I want to know, do I need to rebuild those same containers now that I restarted default, or can I just run docker-compose up?
They are not destroyed. They are stopped though. You can check with
docker ps -a
This will show all containers, stopped and running. In order to start a container
docker start <container name or container id>