How to keep Docker container running after starting services?

I’ve seen a bunch of tutorials that seem do the same thing I’m trying to do, but for some reason my Docker containers exit. Basically, I’m setting up a web-server and a few daemons inside a Docker container. I do the final parts of this through a bash script called run-all.sh that I run through … Read more

How to analyze disk usage of a Docker container

I can see that Docker takes 12GB of my filesystem: 2.7G /var/lib/docker/vfs/dir 2.7G /var/lib/docker/vfs 2.8G /var/lib/docker/devicemapper/mnt 6.3G /var/lib/docker/devicemapper/devicemapper 9.1G /var/lib/docker/devicemapper 12G /var/lib/docker But, how do I know how this is distributed over the containers? I tried to attach to the containers by running (the new v1.3 command) docker exec -it <container_name> bash and then running … Read more

How to rebuild docker container in docker-compose.yml?

There are scope of services which defined in docker-compose.yml. These service have been started. I need to rebuild only one of these and start it without up other services. I run the following commands: docker-compose up -d # run all services docker-compose stop nginx # stop only one. but it still running !!! docker-compose build … Read more

Docker container will automatically stop after “docker run -d”

According to tutorial I read so far, use “docker run -d” will start a container from image, and the container will run in background. This is how it looks like, we can see we already have container id. root@docker:/home/root# docker run -d centos 605e3928cdddb844526bab691af51d0c9262e0a1fc3d41de3f59be1a58e1bd1d But if I ran “docker ps“, nothing was returned. So I … Read more

How to deal with persistent storage (e.g. databases) in Docker

How do people deal with persistent storage for your Docker containers? I am currently using this approach: build the image, e.g. for PostgreSQL, and then start the container with docker run –volumes-from c0dbc34fd631 -d app_name/postgres IMHO, that has the drawback, that I must not ever (by accident) delete container “c0dbc34fd631”. Another idea would be to … Read more

What is the difference between a Docker image and a container?

When using Docker, we start with a base image. We boot it up, create changes and those changes are saved in layers forming another image. So eventually I have an image for my PostgreSQL instance and an image for my web application, changes to which keep on being persisted. What is a container? 3Best Answer … Read more

How do I get into a Docker container’s shell?

I’m getting started working with Docker. I’m using the WordPress base image and docker-compose. I’m trying to ssh into one of the containers to inspect the files/directories that were created during the initial build. I tried to run docker-compose run containername ls -la, but that didn’t do anything. Even if it did, I’d rather have … Read more

Docker: Copying files from Docker container to host

I’m thinking of using Docker to build my dependencies on a Continuous Integration (CI) server, so that I don’t have to install all the runtimes and libraries on the agents themselves. To achieve this I would need to copy the build artifacts that are built inside the container back into the host. Is that possible? … Read more