using docker run -it -v /root/apache-cassandra-3.9:/root/apache-cassandra-3.9 --name=cassan_8 cassan_8
but exiting immediately, no errors in events. Image is created from dockerfile
[root@ip-10-0-1-186 ~]# cat Dockerfile FROM centos:6 RUN yum install -y httpd RUN yum install -y centos-release-scl RUN yum install -y python27 RUN yum install -y java-1.8.0-openjdk ADD apache-cassandra-3.9/bin/cassandra /usr/local/bin ADD cassandra.sh /usr/local RUN chmod 755 /usr/local/cassandra.sh EXPOSE 7000 7001 7199 9042 9160 WORKDIR /root/apache-cassandra-3.9/bin CMD ["/usr/local/cassandra.sh"]
[root@ip-10-0-1-186 ~]# cat cassandra.sh
#!/bin/sh
/root/apache-cassandra-3.9/bin/cassandra -R & >> naresh.txt
You're using cassandra
as the entry point, but you're also sending it to the background:
/root/apache-cassandra-3.9/bin/cassandra -R & >> naresh.txt
Therefore, this line immediately returns. For Docker, as soon as the command has finished, the container has fulfilled its purpose, and therefore, the container is shut down.
Possible approaches to prevent this:
&
(assuming that cassandra keeps running in the foreground and doesn't fork) cassandra.sh
that never returns (a good candidate is tail -f <some logfile>
) waitpid
UPDATE
The advice regarding wait for cassandra is incomplete; a complete minimal solution would be:
/root/apache-cassandra-3.9/bin/cassandra -R & >> naresh.txt
childPID=$!
wait $childPID
(I stole this idea from the startup script used in the official Docker images for Oracle RDBMS )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.