I'd like to set up OpenProject using Docker. There are several decent options in the Hub, but so far I've tried this one as the best possible option. I'd like to clone it, change the database default password (because I find it unsafe) and then build it and run it. How should I proceed?
I've tried docker build -t myrepo/openproject dockerfile_location. Then I get an error that git does not exist. I know that I could add RUN apt-get install git, but afterwards I encounter an error checking for pg_config... no. In order to fix that, I need to install postgres, but this means that I have to put the code and data in the same container. This is the situation that I'm trying to avoid.
How can I solve the problem?
You don't have to put the postgres binaries and data in the same container. pg_config is basically configuring your postgres.
pg_config is in postgresql-devel (libpq-dev in Debian/Ubuntu)
In essence:
# container were your data is
docker run -d --name openproject-postgres-data -v /data busybox true
# container were postgres runs
docker run -d --name openproject-postgres --volumes-from openproject-postgres-data -e USER=super -e PASS=password paintedfox/postgresql
# container that actually runs your application and links to your db container
docker run -d --name openproject --link openproject-postgres:postgres -p 8080:80 abevoelker/openproject
Related
Do I understand Docker correctly?
docker run -it --rm --name verdaccio -p 4873:4873 -d verdaccio/verdaccio
gets verdaccio if it does not exist yet on my server and runs it on a specific port. -d detaches it so I can leave the terminal and keep it running right?
docker exec -it --user root verdaccio /bin/sh
lets me ssh into the running container. However whatever apk package that I add would be lost if I rm the container then run the image again, as well as any edited file. So what's the use of this? Can I keep the changes in the image?
As I need to edit the config.yaml that is present in /verdaccio/conf/config.yaml (in the container), my only option to keep this changes is to detach the data from the running instance? Is there another way?
V_PATH=/path/on/my/server/verdaccio; docker run -it --rm --name
verdaccio -p 4873:4873 \
-v $V_PATH/conf:/verdaccio/conf \
-v $V_PATH/storage:/verdaccio/storage \
-v $V_PATH/plugins:/verdaccio/plugins \
verdaccio/verdaccio
However this command would throw
fatal--- cannot open config file /verdaccio/conf/config.yaml: ENOENT: no such file or directory, open '/verdaccio/conf/config.yaml'
You can use docker commit to build a new image based on the container.
A better approach however is to use a Dockerfile that builds an image based on verdaccio/verdaccio with the necessary changes in it. This makes the process easily repeatable (for example if a new version of the base image comes out).
A further option is the use of volumes as you already mentioned.
I've used docker to install couchbase on my ubuntu machine using (https://hub.docker.com/r/couchbase/server/). The docker run query is as follows:
docker run -d --name db -p 8091-8094:8091-8094 -p 11210:11210 -v /home/dockercontent/couchbase:/opt/couchbase/var couchbase
Everything works perfectly fine. My application connects, I'm able to insert/update and query the couchbase. Now, I'm looking to debug a situation wherein the couchbase is on my co-developers machine who also has the same installation i.e., couchbase on docker using the above link. For achieving this, I wanted to run cbbackup on his installation. To achieve this, I run the following command which is a variation of the above link:
bash -c "clear && docker exec -it couch-db sh"
Can anyone please help me with the location of /opt/couchbase/bin in this setup? I believe this is where I can get access to "cbbackup", "cbrestore" and "cbtransfer" which I can then use to backup and restore data from my colleague's machine.
Thanks,
Abhi.
When you run the command
docker run -d --name db -p 8091-8094:8091-8094 -p 11210:11210 -v /home/dockercontent/couchbase:/opt/couchbase/var couchbase
you're pulling a docker image and spawning a docker container.
Please read more about Docker and containerization.
In order to run cbbackup you need to log into your docker container.
Follow these steps:
Retrieve the container-id:
$ docker ps -a
Look for the CONTAINER ID for IMAGE NAME=couchbase
Login to the container using the command:
$ docker exec -it <container-id> bash
Go to the directory : /opt/couchbase/bin using:
$ cd /opt/couchbase/bin
You'll find cbbackup binary in this directory.
I am using nodeBB to start a server you can run ./nodebb start to stop you can do ./nodebb stop. Now that I have dockerized it http://nodebb-francais.readthedocs.org/projects/nodebb/en/latest/installing/docker/nodebb-redis.html I am not sure how I can interact with it.
I have followed the steps "Using docker-machine mac os x"
docker run --name my-forum-redis -d -p 6379:6379 nodebb/docker:ubuntu-redis
Then
docker run --name my-forum-nodebb --link my-forum-redis:redis -p 80:80 -p 443:443 -p 4567:4567 -P -t -i nodebb/docker:ubuntu
Then
docker start my-forum-nodebb
I had an issue with redis address in use, so I want to fix that and restart but I am not sure how? Also I would like to issue the command grunt in the project directory, again not sure how?
My question is how can I interact with an app inside a docker container as if I had direct access to the project folder itself? Am I missing something?
All code in this answer is untested, as I'm currently at a computer without docker.
See whether the containers are still running
docker ps
Stop misconfigured containers
docker stop my-forum-redis
docker stop my-forum-nodebb
Remove misconfigured containers and their volumes
(The docker images they are based on will be retained.)
docker rm --volumes --force stop my-forum-nodebb
docker rm --volumes --force my-forum-redis
Start again
Then, issue your 3 commands again, now with the correct ports.
Execute arbitrary commands inside container
Also I would like to issue the command grunt in the project directory, again not sure how?
You probably want to do the following after the docker run --name my-forum-nodebb ... command but before docker start my-forum-nodebb.
docker run accepts a command to execute instead of the container's default command. Let's first use this to find out where in the container we'd land:
docker run my-forum-nodebb pwd
If that is the directory where you want to run grunt, just go forward with it:
docker run my-forum-nodebb grunt
If not, you'll have to stuff several commands into a single one. You can do that by invoking a shell:
docker run my-forum-nodebb bash -c 'cd /path/to/project/dir; grunt'
where /path/to/project/dir is to be replaced by where you want to run grunt.
I would like to know if it is recommended to use that image in production environment. Or should I install Openshift Natively?
If I can use the docker image in production how should I upgrade it when a new version of image is released? I know I lose all configuration and application definition when starting a new docker container. Is there a way to keep them? Mapping volumes? Which volumes should be mapped?
The command line I am using is:
$ sudo docker run -d --name "origin" \
--privileged --pid=host --net=host \
-v /:/rootfs:ro -v /var/run:/var/run:rw -v /sys:/sys -v /var/lib/docker:/var/lib/docker:rw \
-v /var/lib/origin/openshift.local.volumes:/var/lib/origin/openshift.local.volumes \
openshift/origin start
PS. There is a relative question I asked yesterday but not focusing on the same problem.
Update on 20/01/2016
I have tried #Clayton's suggestion of mapping folder /var/lib/origin which worked well before 17th Jan 2016. Then I started getting Failed to mount issue when deploying router and some other applications. When I change it back to mapping /var/lib/origin/openshift.local.volumes, it seems OK until now.
If you have the /var/lib/origin directory mounted, when your container reboots you will still have all your application data. That would be the recommended way to run in a container.
I'm trying to use Rstudio on a DigitalOcean server using the Rstudio docker. Since my experience with linux servers is limited, it's been a bit of a challenge for me.
I'm able to get Rstudio up and running with:
docker run -dp 8787:8787 -v /root:/home/rstudio/ -e ROOT=TRUE rocker/hadleyverse
However, I'd like to be able to shut down the server and save it to a snapshot when I'm not using it, but not have to re-install packages each time I do so.
Using the the docker documentation on updating an image, I am able to create a container, install packages on that container, and then commit the changes:
docker run -t -i rocker/hadleyverse /bin/bash
install.r randomForest
exit
docker commit \<CONTAINER_ID> michael91/ms:v1
However, once I make the commit, I am unable to run the updated image properly. I try and run it as follows:
docker run -dp 8787:8787 -v /root:/home/rstudio/ -e ROOT=TRUE michael91/ms:v1
When I do so, Rstudio server is not activated, as it is when I run the original rocker/hadleyverse version. I've tried making commits with and without installing packages; either way it doesn't seem to work. Obviously I'm doing something incorrectly, but I'm not sure what. If anyone could offer me some guidance, I'd really appreciate it.
Edit: Thanks a lot VonC; that did the trick.
It could be because the new committed image has lost its CMD directive that was present in rocker-org/rocker/rstudio/Dockerfile#L58.
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d /supervisord.conf"]
Try and create a new Dockerfile:
FROM michael91/ms:v1
## Add RStudio binaries to PATH
ENV PATH /usr/lib/rstudio-server/bin/:$PATH
ENV LANG en_US.UTF-8
EXPOSE 8787
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
And build it as michael91/ms:v2.
Then see v2 works better than v1 when it comes to activating RStudio:
docker run -dp 8787:8787 -v /root:/home/rstudio/ -e ROOT=TRUE michael91/ms:v2