0

To deal with data going away once the container is shut,

I'm trying to implement a command to mount a persistent volume. That way, people can swap the containers(for upgrades, etc) aggressively without fearing loss of data.

root@docker-ubuntu-9:~/apache2-Docker# docker run -it -d -p 9000:9000 -p 8000:8000 -P --name mavenLOG -v /root/apache2-Docker/mavenLOG/:/var/log maven-apache2-test02 
27125546z622992f301788c49ab99279cfe71e30a399b26bbc8a5c83050cd56c
root@docker-ubuntu-9:~/apache2-Docker#
root@docker-ubuntu-9:~/apache2-Docker# docker ps -a
CONTAINER ID        IMAGE                     COMMAND                  CREATED             STATUS                      PORTS                    NAMES
27125546z622        maven-apache2-test02            "/usr/bin/supervisord"   16 seconds ago      Exited (2) 16 seconds ago                            mavenLOG

Want:

(1) Host has this folder

root@docker-ubuntu-9:~/apache2-Docker# ls 
all-in-one  mavenLOG

(2) Container has /var/log going on and writes when apps start

(3) I want to new containers to respect the data already present and NOT overwrite or replace but read and write from then on

(4) We have existing ports being used that I used to spawn with "docker run -it -d -p 9000:9000 -p 8000:8000 maven-apache2-test02" BEFORE the persistent command

But container keeps on dying. What am I doing wrong here?

Is simply volume/folder mapping not allowed in Docker? I don't need to mount any new volumes on the container.

[Update:]

root@docker-ubuntu-9:~# docker logs 27125546z622
/usr/lib/python2.7/dist-packages/supervisor/options.py:295: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
  'Supervisord is running as root and it is searching '

But this solved it,

root@docker-ubuntu-9:~/apache2-Docker/apache2-maven# docker run -it -d -p 9000:9000 -p 8000:8000 -P --name mavenLOG -v /root/apache2-Docker/mavenLOG/:/var/log maven-apache2-test02 /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
06eff95ea56bfe5333e5b7bc0420530fb879bd922ff13b11435e19fac734eb31
root@docker-ubuntu-9:~/apache2-Docker/apache2-maven# 
root@docker-ubuntu-9:~/apache2-Docker/apache2-maven# 
root@docker-ubuntu-9:~/apache2-Docker/apache2-maven# docker ps
CONTAINER ID        IMAGE                     COMMAND                  CREATED             STATUS              PORTS                                            NAMES
06eff95ea56b        maven-apache2-test02            "/usr/bin/supervisord"   4 seconds ago       Up 3 seconds        0.0.0.0:9000->9000/tcp, 0.0.0.0:8000->8000/tcp   mavenLOG

So now my "log" will be populated with container's "/var/log"?

  • could you post the Dockerfile and the log of the dead container (docker log 27125546z622)? – mrc Apr 5 '16 at 8:41
0

(3) I want to new containers to respect the data already present and NOT overwrite or replace but read and write from then on

As mentioned by @Mario, this depends on the "maven-apache2-test02" container. However, this is do-able. I quickly created a setup, take a look here.

As you can see from the demo that, two different containers can write to same file from the host concurrently respecting the already exiting data

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.