I have a problem with my Dockerfile. I installed py-spidev on my Docker container to fetch data from a sensor.
Everything works and is installed in the container.
My only problem is that the folder /dev/spi* has only read-write rights for root. I need reading rights on www-data. If I execute a chmod 666 /dev/spi* on a running container, everthing works fine. I want that the chmod to be executed in the Dockerfile.
https://github.com/legionth/westfall-pi/blob/master/Dockerfile
In your Dockerfile, just add this line:
RUN chmod 666 /dev/spi*
Related
I want to have an auto start script for my project. I use docker and want to try a script that starts if the container start.
I tried to run update-rc and i dont have any problems but the symbolic links dont get generated. I checked it in the file explorer and with my script:
mkdir /var/www/$(date +%Y%m%d_%H%M%S)
But nothing happend.
This is in my dockerfile:
COPY starter.sh /etc/init.d/starter.sh
RUN chmod +x /etc/init.d/starter.sh
RUN chmod 755 /etc/init.d/starter.sh
RUN update-rc.d starter.sh defaults 10
I dont get any error messages. Thats my problem :)
Use the below instructions in your docker file:
COPY starter.sh /starter.sh
RUN chmod +x /starter.sh && chmod 0755 /starter.sh
ENTRYPOINT ["/starter.sh"]
CMD ["defaults", "10"]
The things in RUN statements are executed during image build time. They can generate files in the Docker image, but not create processes which remain running after the image build finishes (how would that even work?)
The simplest solution is probably to create an entry point which starts your service(s) and then runs any user-supplied commands.
I want to have a script that runs in my docker container at every start/restart. It should run the bash of the container with:
cd app
Console/cake schema update
and
Console/cake migration
I tired to run a process or write something in my dockerfile, but that all doesnt work for me. I also read the "Run multiple services in a container" from docker, but i didnt find a solution.
COPY starter.sh /etc/init.d/starter.sh
RUN chmod +x /etc/init.d/starter.sh
RUN chmod 755 /etc/init.d/starter.sh
RUN update-rc.d starter defaults 10
RUN /etc/init.d/starter.sh
in my starter.sh is some test code like
RUN mkdir /var/www/hello
that i know if it works
Make use of ENTRYPOINT in dockerfile
Add these lines in dockerfile
COPY starter.sh /opt/starter.sh
ENTRYPOINT ["/opt/starter.sh"]
Update:
If you want to run apache web server then add these lines
ENTRYPOINT ["/path/to/apache2"]
CMD ["-D", "FOREGROUND"]
This will run apache2 as first process inside container in daemon mode.
I have several files in a directory on the host machine which I am trying to copy to the container and also have some run commands inside my docker-compose.
The first set up until the crowd section stats woks fine, but anything from the crown jar down just fails and doesn't work. I tried to run the manial docker cp command to copy the files from host to the container and that works. Can someone please shed some light on this?
This is a part of my Dockerfile:
WORKDIR /usr/local/tomcat
USER root
COPY server.xml conf/server.xml
RUN chmod 660 conf/server.xml
USER root
ADD tomcat.keystore /usr/local/tomcat/
RUN chmod 644 tomcat.keystore
RUN chown root:staff /usr/local/tomcat/tomcat.keystore
ADD crowd-auth-filter-1.0.0.jar /usr/local/tomcat/webapps/guacamole/WEB-INF/lib/
ADD crowd-filter.properties /usr/local/tomcat/webapps/guacamole/WEB-INF/lib/
RUN chmod 644 crowd-filter.properties
ADD web.xml /usr/local/tomcat/webapps/guacamole/WEB-INF/
RUN /usr/local/tomcat/bin/shutdown.sh
RUN /usr/local/tomcat/bin/startup.sh
Thanks
I have followed a guide to dockerise an Elixir/Phoenix project and I created a bash script, but docker doesn't have permssion to execute the file. I ran
docker-compose build
chmod u+x entrypoint.sh
docker-compose up
despite running the commands it still doesn't have permission. What am I doing wrong?
It is better to do the chmod inside a custom Dockerfile, build your own image, and run it through docker-compose as shown below,
RUN chmod +x entrypoint.sh
Doing it directly on the host works only if the docker compose is mounting that file as a volume bind when running the image..
As mentioned by VonC, you might need to create a custom docker image. Copy the file inside the image and then change the permission. You can look at an example of initializing a SQL Server 2017 database using entry point.sh at
https://www.handsonarchitect.com/2018/01/build-custom-sql-server-2017-linux.html
I'm trying to write a Dockerfile file to run Pydio community edition. I've an almost working Dockerfile.
RUN mv pydio-core-${PYDIO_VERSION} /var/www/pydio-core
RUN chmod -R 770 /var/www/pydio-core
RUN chmod -R 777 /var/www/pydio-core/data/files/ /var/www/pydio-core/data/personal/
RUN chown -R www-data:www-data /var/www/pydio-core
VOLUME /var/www/pydio-core/data/files
VOLUME /var/www/pydio-core/data/personal
This works except that when the container is started for the first time, the access rights of the files and personal folders is 755 and their owner is not www-data but 1000. So once started, I must connect the container to fix permissions (770) and ownership (www-data) and everything works.
I just wonder if it may have something in my Dockerfile which could explain the problem, or if the issue probably comes from the Pydio source code itself.