Dokku run with --rm flag - dokku

According to the dokku guide for schedule tasks(cron) To remove a container after dokku run we should use dokku --rm run....
I got a wierd issue with that,
when I run for example
dokku run APP bundle exec rake db:migrate
Everything works fine,
but when trying to run it with --rm flag
I get a
'db:migrate APP` is not a dokku command.

I had the same kind of problem (basically everything I got was an is not a dokku command error) and I manage to solve it by changing crontab file with the following approach.
Original example line from crontab configuration file was like:
0 * * * * dokku dokku --rm run app bundle exec rake a:task
After changing it to:
0 * * * * dokku --rm run app bundle exec rake a:task
the cron began to work as expected (e.g. I can tail mail sent by crontab by doing tail -f /var/mail/dokku).
I don't know exactly why this solution works, but it does.

Related

I keep getting this error "docker: invalid reference format: repository name must be lowercase."

I keep getting this error even my repo name is lowercase, the code i´m running is this sudo docker container run --rm -p 3838:3838 -v /home/ubuntu/la-liga-2018-2019-stats/stats/:/srv/shiny-server/stats -v /home/ubuntu/log/shiny-server/:/var/log/shiny-server/
BorisRendon/shinyauth. I´m trying to deploy a shiny app to aws using docker and i can´t pass this step.
You should probably use docker run and not docker container run.

unable to run R script in crontab in docker container

I'm trying to run a R script inside docker container. Here is the example.
My working directory is like below.
myRDocker
-dockerfile
-scripts
-save_iris.R
In the directory myRDocker, there is a dockerfile and a directory scripts, which contains a R script save_iris.R
My R script save_iris.R is like below:
write.csv(iris, '/data/iris.csv')
My dockerfile is like below:
# Install R version 3.6
FROM r-base:3.6.0
#install crontab
RUN apt-get update && apt-get -y install cron
RUN mkdir /data
COPY /scripts /scripts
I went to my directory myRDocker and build docker image
docker build -t baser .
I run the docker container in bash.
docker run -it baser bash
After I get into the container, I did:
crontab -e
then add this line, then save
* * * * * Rscript /scripts/save_iris.R
It should save the file to the folder /data every min. However, I never found any file in the data folder inside the container.
My question is:
what did I do wrong in the above procedure? I feel like I might be missing something.... but could not figure out why...
what should I do if I want to run the scheduled cron task whenever container start. (something like put the cron task in a file, and run when container start....)
why you are not starting the cronjob on container run time, instead of running after container start? Also, I do not think the crontab process will run in your case as your container is not doing any thing.
Try this, which will start cron on container run time and will also tail logs of cron job. but keep in mind your main process in this case is tail -f /var/log/cron.log not the cron process.
FROM r-base:3.6.0
RUN apt-get update && apt-get -y install cron
RUN touch /var/log/cron.log
COPY hello.r /hello.r
RUN (crontab -l ; echo "* * * * * Rscript /hello.r >> /var/log/cron.log") | crontab
# Run the command on container startup
CMD cron && tail -f /var/log/cron.log
So you will get the Rscript console logs to Container stdout.
hello.r
print("Hello World from R")

Logs via qDebug() are invisible when run via docker-compose

I have written a Qt application which logs to console via qDebug(). When run inside a docker container, the application logs are visible as normal. But when the same docker image is run via docker-compose up, there is no output visible at all. How does this come?
Edit:
The output is not visible either, if I try to view it via docker logs in the following way:
docker run -d --rm -name test test-image
docker logs test
Working:
docker run -it --rm test-image
I finally found a solution. My docker run was missing the -t flag:
docker run -it --rm -t test-image
The equivalent option for the docker-compose config is:
tty: true
Hope this is helpfull to someone.

Pass parameters to docker container using docker run command

I have created a docker image using Dockerfile mentioned below. There is a jar file in the image which needs few parameters to run it. I am passing the parameters using docker run command but it throws me error. Find the details below.
Dockerfile content
FROM ubuntu:14.04
ENV http_proxy http://http.proxy.nxp.com:7000
ENV https_proxy http://http.proxy.nxp.com:7000
RUN apt-get update
<set of lines for installing java is here>
ENV JAVA_HOME /usr/lib/jvm/java-8-oracle
copy apache-jmeter-3.1 /apache-jmeter-3.1
RUN mkdir /jarloc
copy Test.jar /jarloc
RUN java -version
ENTRYPOINT [ java -jar /jarloc/Test.jar ]
RUN ls -l /jarloc
I created an image called as jmaster:1.0 and gave following command to spin the container.
docker run jmaster:1.0 http://win_loc/soasta_parent/soasta/MyPOC/Login_Data.csv http://win_loc/soasta_parent/soasta/MyPOC/Dpc_data.csv 30 300 30
This gives me following error.
http://win_loc/soasta_parent/soasta/MyPOC/Login_Data.csv: 1: [:
missing ]
I am able to run this script from inside docker (docker run -it jmaster:1.0 /bin/bash). It gives me correct output. But when I try to pass the parameter in docker run command, I am getting this error. Am I passing this in a wrong way or is there any other way to do so?
When I go inside docker using 'docker run -it imagename /bin/bash' and execute following, I am getting correct results from jar.
/jarloc#java -jar Test.jar http://win_loc/soasta_parent/soasta/MyPOC/Login_Data.csv http://win_loc/soasta_parent/soasta/MyPOC/Dpc_data.csv 30 300 30
Try with
ENTRYPOINT ["java","-jar","/jarloc/Test.jar"]
That should take the parameters in docker run

how can I set the working directory in old version of docker in the run command?

I am a bit new to docker and I have been trying to run deploy a meteor container with my meteor application. I have been using the dockerfile and instructions from https://registry.hub.docker.com/u/golden/meteor-dev/
However, I cant run docker run -p 3000:3000 -t -i -v /path/to/meteor/app:/opt/application -w /opt/application meteor-dev because my docker (version 0.5.3) does not recognize the flag (-w) to set the working directory.
Is there some workaround to set the working directory with docker 0.5.3? The work directory is already set in the docker file, but I guess I need to set it again when I run the container.
well, my workaround was to create a bash script that would go to the working directory and call the commands one by one. I created the bash script where my source is located "/path/to/meteor/app" and call docker run -p 3000:3000 -t -i -v /path/to/meteor/app:/opt/application meteor-dev bash /opt/application/start.sh with the bash as command and my script as argument

Resources