1

The question is very basic, but I couldn't found any solution

Dockerfile

FROM ubuntu:14.04
COPY . ./myapp
WORKDIR ./myapp
CMD ./myappexecutable

Commands to build and run

sudo docker build -t myapp .
sudo docker run -p 6060:6060 -v /home/usr/data:/root/data myapp
  1. How can I keep up this container?

When I try run container, its status exited.

CMD tail -f info.log

When I try to tail any file it keeps up but not really works my app also it seems not a good way.

  1. Does docker have any method to mount volume while building? Doesn't docker support it because of portability?
İlker Korkut
  • 3,129
  • 3
  • 30
  • 51

1 Answers1

0

1/ How can I keep up this container?

you can consider using baseimage-docker, which allows you to make any app as a daemon, and deal with SIGTERM signal (send by a docker stop)

2/ Does docker have any method to mount volume while building?

No, that would break portability, as mentioned i n "How to mount host volumes into docker containers in Dockerfile during build", and in issue 3156.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks for your advice , I tried baseimage-docker and that's what I want exactly. However when I change with `RUN ./myappexecutable` my CMD line the executable is not running. But when I attach container's bash and write command manually it works. How can I achieve this problem ? – İlker Korkut Oct 11 '15 at 19:09
  • @İlkerKorkut see https://github.com/phusion/baseimage-docker#getting-started: `CMD` is supposed to be `/sbin/my_init` (which comes from https://github.com/phusion/baseimage-docker/blob/master/image/bin/my_init) – VonC Oct 11 '15 at 19:18
  • @İlkerKorkut Then see https://github.com/phusion/baseimage-docker#adding_additional_daemons: "You can add additional daemons (e.g. your own app) to the image by creating runit entries.". "The shell script must be called `run`, must be executable, and is to be placed in the directory `/etc/service/`." – VonC Oct 11 '15 at 19:19
  • `/var/lib/docker/aufs/mnt/519f4c698c95ab6f5ec5a14b132939e24d77c333763d58cd7332fd8741936a87/etc/service/myappservice/startmyapp.sh : not a directory` I added that command according to adding additional daemons. It gives that error now. `RUN mkdir /etc/service/myappservice` `ADD start-myapp.sh /etc/service/myappservice` – İlker Korkut Oct 11 '15 at 19:41
  • @İlkerKorkut What happened to "The shell script must be called `run`"? (from https://github.com/phusion/baseimage-docker#adding_additional_daemons) – VonC Oct 11 '15 at 19:50
  • yes I call with `RUN` but no way , btw I am able to run myapp with docker exec while container is up, which is nice ability for my container. – İlker Korkut Oct 11 '15 at 19:53
  • @İlkerKorkut I mean if I understand the doc, I suppose the script running your app should be called "run" (nothing to do with how you call it, and everything with how the base image detects that it must run your app) – VonC Oct 11 '15 at 20:07