I'm using Docker to host a Jena/Fuseki container. I have a very outdated Fuseki instance on another server that I would like to migrate the data from. I've backed up the old server into a .nq file, but I can't create a new datastore with this file.
Dockerfile:
FROM openjdk:10
ENV JENAVERSION=3.7.0
ENV FUSEKI_HOME=/fuseki
RUN mkdir /fuseki
RUN mkdir /jena
RUN wget http://apache.claz.org/jena/binaries/apache-jena-fuseki-$JENAVERSION.tar.gz -P /tmp \
&& tar -zxvf /tmp/apache-jena-fuseki-$JENAVERSION.tar.gz -C /tmp \
&& mv -v /tmp/apache-jena-fuseki-$JENAVERSION/* /fuseki
RUN wget http://apache.claz.org/jena/binaries/apache-jena-$JENAVERSION.tar.gz -P /tmp \
&& tar -zxvf /tmp/apache-jena-$JENAVERSION.tar.gz -C /tmp \
&& mv -v /tmp/apache-jena-$JENAVERSION/* /jena
EXPOSE 3030
ENTRYPOINT ["/bin/bash", "/fuseki/fuseki-server"]
Docker-Compose file:
version: '2'
services:
fuseki_test:
build:
context: /docker/buildfiles/
dockerfile: /docker/buildfiles/fuseki
restart: unless-stopped
ports:
- "19095:3030"
volumes:
- "/docker/jena2/databases/data:/run/databases/PDE_PROD"
- "/docker/jena2/backups:/run/backups"
- "/docker/jena2/shiro.ini:/run/shiro.ini:ro"
- "/docker/jena2/fuseki-tdb2.ttl:/run/config.ttl:ro"
- "/docker/data:/staging"
environment:
- ADMIN_PASSWORD=password
- JVM_ARGS=-Xmx16g
Here's the command I used to try to load the data:
/bin/bash /jena/bin/tdb2.tdbloader --loc=/run/databases/PDE_PROD /staging/PDE_DEV_2_2018-02-15_12-51-30.nq
Everything loads without errors, the data shows up in the folder I would expect, no errors starting Fuseki, but no triples show up.
Related
I am deploying on AWS clamav
whos Dockerfile is :
FROM alpine:3.14
LABEL maintainer="Markus Kosmal <code#m-ko.de>"
RUN apk add --no-cache bash clamav clamav-daemon clamav-libunrar
COPY conf /etc/clamav
COPY bootstrap.sh /
COPY envconfig.sh /
COPY check.sh /
RUN mkdir /var/run/clamav && \
chown clamav:clamav /var/run/clamav && \
chmod 750 /var/run/clamav && \
chown -R clamav:clamav bootstrap.sh check.sh /etc/clamav && \
chmod u+x bootstrap.sh check.sh
EXPOSE 3310/tcp
USER clamav
CMD ["/bootstrap.sh"]
and since I am using a mirror I am testing locally using a docker-compose file
version: "3.7"
services:
mirror:
build:
context: .
dockerfile: mirror/Dockerfile
ports:
- "8080:8080"
clamav:
build:
context: ../clamav
environment:
CLAMAVDATABASEMIRROR: "http://0.0.0.0:8080"
depends_on:
- mirror
ports:
- "3310:3310"
services work fine and when I run docker-compose up --build I can see from the logs that the services is pulling the daily update and stuff.
if I run docker container ls
I get that clamav has ports: 3310/tcp wheras the mirror has a mapped port on my local host
0.0.0.0:8080->8080/tcp
and I can run curl localhost:8080
But If I try and curl localhost on 3310 I get
curl: (52) Empty reply from server
now: how do I perform a healthcheck on the clamav service?
I have two questions:
Dockerfile has two command, add group and user, both named www, but didn't create.
How to stop the container created by docker-compose up -d.
I followed this article:
https://www.digitalocean.com/community/tutorials/how-to-set-up-laravel-nginx-and-mysql-with-docker-compose
git clone https://github.com/laravel/laravel.git mylaravel9
Edit docker-compose.yml and Dockerfile, then
docker-compose up -d
The browser "http://localhost" shows, but with an error, a log file with permission problem. This was solved, but not really solved.
docker-compose.yml
version: '3'
services:
#PHP Service
app:
build:
context: .
dockerfile: Dockerfile
image: php:8.1.4-fpm
container_name: app
restart: unless-stopped
tty: true
environment:
SERVICE_NAME: app
SERVICE_TAGS: dev
working_dir: /var/www
volumes:
- ./:/var/www
- ./php/local.ini:/usr/local/etc/php/conf.d/local.ini
networks:
- app-network
#Nginx Service
webserver:
image: nginx:alpine
container_name: webserver
restart: unless-stopped
tty: true
ports:
- "80:80"
- "443:443"
volumes:
- ./:/var/www
- ./nginx/conf.d/:/etc/nginx/conf.d/
networks:
- app-network
#MySQL Service
db:
image: mysql:5.7.22
container_name: db
restart: unless-stopped
tty: true
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: laravel
MYSQL_ROOT_PASSWORD: 123456
SERVICE_TAGS: dev
SERVICE_NAME: mysql
volumes:
- dbdata:/var/lib/mysql/
- ./mysql/my.cnf:/etc/mysql/my.cnf
networks:
- app-network
#Docker Networks
networks:
app-network:
driver: bridge
#Volumes
volumes:
dbdata:
driver: local
Dockerfile:
FROM php:8.1.4-fpm
# Copy composer.lock and composer.json
COPY composer.lock composer.json /var/www/
# Set working directory
WORKDIR /var/www
# Install dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libpng-dev \
libjpeg62-turbo-dev \
libfreetype6-dev \
locales \
zip \
jpegoptim optipng pngquant gifsicle \
vim \
unzip \
git \
curl
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install extensions
RUN docker-php-ext-install pdo_mysql zip exif pcntl
RUN docker-php-ext-configure gd --with-gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include/
RUN docker-php-ext-install gd
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Add user for laravel application
RUN groupadd -g 1000 www
RUN useradd -u 1000 -ms /bin/bash -g www www
# Copy existing application directory contents
COPY . /var/www
# Copy existing application directory permissions
COPY --chown=www:www . /var/www
# Change current user to www
USER www
# Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm"]
The first question:
When first time do
docker-compose up -d
It pulls things, and run the commands in Dockerfile. There is a problem, which is also solved
failed to solve: executor failed running [/bin/sh -c docker-php-ext-install pdo_mysql mbstring zip exif pcntl]: exit code: 1
A post says the "mbstring" needs to be taken off. Ok, the Dockerfile really used. But there are two commands not working
# Add user for laravel application
RUN groupadd -g 1000 www
RUN useradd -u 1000 -ms /bin/bash -g www www
Because
docker exec -it app bash
and in the app container's shell
cd /var/www
ls -l
I saw the group and owner is number 1000, not www. Then
cat /etc/passwd
The user and group of "www" doesn't exist! Why?
I manually add the www group and user, and do chmod, the problem of log file permission is solved. But why www doesnt exist? The add commands are in the Dockerfile.
The second question
Exit the app shell, back to Ubuntu
docker ps
Shows three conatiners: php, nginx, mysql. But in docker interface(Windows 11), there is a container named by the folder mylaravel9.
docker stop mylaravel9
It says:
Error response from daemon: No such container: mylaravel9
So I can only stop the whole thing in the docker UI? If I want to use command, I have to stop the three containers? Is it?
There are two significant problems in the setup you show.
volumes:
- ./:/var/www
In the Dockerfile, you COPY --chown content to a different user, but then this volumes: mount hides everything the image setup does in the /var/www directory and replaces it with content from the host. Inside the container you'll see the host's numeric user ID and the possibly-unrelated code from the host. I'd recommend just deleting this line.
build: .
image: php:8.1.4-fpm
This combination tells Compose to build your application from its Dockerfile, then to label the result as the original php:8.1.4-fpm image. When you re-run docker-compose build it will start from the thing labeled as php:8.1.4-fpm, which means you're repeatedly reinstalling your application on top of itself.
Delete the image: line if you're not planning to push the built image to a registry (and if you are, use the name and tag for the built image, not the base image). docker pull php:8.1.4-fpm manually to make sure you have a "good" copy of this base image.
In the context of a Compose project, you don't usually need to use basic docker commands; there are docker-compose wrappers for most operations. If you want to update your application and restart its container it should be enough to
docker-compose build
docker-compose up -d
will will recreate the changed app container but leave the others alone. If you do need to stop an individual container for some reason ("stopped" is a somewhat unusual state) then docker-compose stop can do it.
I have an existing docker-compose file
version: '3.6'
services:
verdaccio:
restart: always
image: verdaccio/verdaccio
container_name: verdaccio
ports:
- 4873:4873
volumes:
- conf:/verdaccio/conf
- storage:/verdaccio/storage
- plugins:/verdaccio/plugins
environment:
- VERDACCIO_PROTOCOL=https
networks:
default:
external:
name: registry
I would like to use an DockerFile instead of docker-compose as it will be more easy to deploy DockerFile on an Azure container registry.
I have tried many solution posted on blogs and others but nothing worked as I needed.
How can I create simple DockerFile from the above docker-compose file?
You can't. Many of the Docker Compose options (and the equivalent docker run options) can only be set when you start a container. In your example, the restart policy, published ports, mounted volumes, network configuration, and overriding the container name are all runtime-only options.
If you built a Docker image matching this, the most you could add in is setting that one ENV variable, and COPYing in the configuration files and plugins rather than storing them in named volumes. The majority of that docker-compose.yml would still be required.
If you want to put conf, storage and plugins files/folders into image, you can just copy them:
FROM verdaccio/verdaccio
WORKDIR /verdaccio
COPY conf conf
COPY storage storage
COPY plugins plugins
but if you need to keep files/and folder changes, then you should keep them as it is now.
docker-compose uses an existing image.
If what you want is to create a custom image and use it with your docker-compose set up this is perfectly possible.
create your Dockerfile - example here: https://docs.docker.com/get-started/part2/
build an "image" from your Dockerfile: docker build -f /path/to/Dockerfile -t saurabh_rai/myapp:1.0 this returns an image ID something like 12abef12
login to your dockerhub account (saurabh_rai) and create a repo for the image to be pushed to (myapp)
docker push saurabh_rai/myapp:1.0 - will push your image to hub.docker.com repo for your user to the myapp repo. You may need to perform docker login for this to work and enter your username/password as usual at the command line.
Update your docker-compose.yaml file to use your image saurabh_rai/myapp:1.0
example docker-compose.yaml:
version: '3.6'
services:
verdaccio:
restart: always
container_name: verdaccio
image: saurabh_rai/myapp:1.0
ports:
- 4873:4873
volumes:
- conf:/verdaccio/conf
- storage:/verdaccio/storage
- plugins:/verdaccio/plugins
environment:
- VERDACCIO_PROTOCOL=https
network:
- registry
I have solve this issue by using an existing verdaccio DockerFile given below.
FROM node:12.16.2-alpine as builder
ENV NODE_ENV=production \
VERDACCIO_BUILD_REGISTRY=https://registry.verdaccio.org
RUN apk --no-cache add openssl ca-certificates wget && \
apk --no-cache add g++ gcc libgcc libstdc++ linux-headers make python && \
wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \
wget -q https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.25-r0/glibc-2.25-r0.apk && \
apk add glibc-2.25-r0.apk
WORKDIR /opt/verdaccio-build
COPY . .
RUN yarn config set registry $VERDACCIO_BUILD_REGISTRY && \
yarn install --production=false && \
yarn lint && \
yarn code:docker-build && \
yarn cache clean && \
yarn install --production=true
FROM node:12.16.2-alpine
LABEL maintainer="https://github.com/verdaccio/verdaccio"
ENV VERDACCIO_APPDIR=/opt/verdaccio \
VERDACCIO_USER_NAME=verdaccio \
VERDACCIO_USER_UID=10001 \
VERDACCIO_PORT=4873 \
VERDACCIO_PROTOCOL=http
ENV PATH=$VERDACCIO_APPDIR/docker-bin:$PATH \
HOME=$VERDACCIO_APPDIR
WORKDIR $VERDACCIO_APPDIR
RUN apk --no-cache add openssl dumb-init
RUN mkdir -p /verdaccio/storage /verdaccio/plugins /verdaccio/conf
COPY --from=builder /opt/verdaccio-build .
ADD conf/docker.yaml /verdaccio/conf/config.yaml
RUN adduser -u $VERDACCIO_USER_UID -S -D -h $VERDACCIO_APPDIR -g "$VERDACCIO_USER_NAME user" -s /sbin/nologin $VERDACCIO_USER_NAME && \
chmod -R +x $VERDACCIO_APPDIR/bin $VERDACCIO_APPDIR/docker-bin && \
chown -R $VERDACCIO_USER_UID:root /verdaccio/storage && \
chmod -R g=u /verdaccio/storage /etc/passwd
USER $VERDACCIO_USER_UID
EXPOSE $VERDACCIO_PORT
VOLUME /verdaccio/storage
ENTRYPOINT ["uid_entrypoint"]
CMD $VERDACCIO_APPDIR/bin/verdaccio --config /verdaccio/conf/config.yaml --listen $VERDACCIO_PROTOCOL://0.0.0.0:$VERDACCIO_PORT
By making few changes to the DockerFile I was able to build and push my docker image to azure container registry and deploy to an app service.
#Giga Kokaia, #Rob Evans, #Aman - Thank you for the suggestions it became more easy to think.
I have several files in a directory on the host machine which I am trying to copy to the Docker container.
The problem is that the files do get copied to the destination but all the existing files inside the destination directory get removed.
Before adding these new ADD lines to my Dockerfile, I had like 20 jar files in the lib directory, by adding these ADD lines the two crowd files below, all 20 existing jar files get deleted and the directory will now contains only two crowd files which were just copied from the host into the container!
I tried without the user ROOT but it would not copy the server.xml and tomcat.keystore
FROM guacamole/guacamole
RUN sed -i 's/redirectPort="8443"/redirectPort="8443" server="" secure="true"/g' /usr/local/tomcat/conf/server.xml \
&& sed -i 's/<Server port="8005" shutdown="SHUTDOWN">/<Server port="-1" shutdown="SHUTDOWN">/g' /usr/local/tomcat/conf/server.xml \
&& rm -rf /usr/local/tomcat/webapps/docs/* \
&& rm -rf /usr/local/tomcat/webapps/examples/* \
&& rm -rf /usr/local/tomcat/webapps/manager/* \
&& rm -rf /usr/local/tomcat/webapps/host-manager/*
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 ./lib/crowd-auth-filter-1.0.0.jar /usr/local/tomcat/webapps/guacamole/WEB-INF/lib/crowd-auth-filter-1.0.0.jar
ADD ./lib/crowd-filter.properties /usr/local/tomcat/webapps/guacamole/WEB-INF/lib/crowd-filter.properties
RUN chmod 644 /usr/local/tomcat/webapps/guacamole/WEB-INF/lib/crowd-filter.properties
ADD web.xml /usr/local/tomcat/webapps/guacamole/WEB-INF/web.xml
CMD /usr/local/tomcat/bin/shutdown.sh && /usr/local/tomcat/bin/startup.sh
docker-compose.yml:
version: '2'
services:
guacd:
hostname: guacd
image: guacamole/guacd
restart: always
container_name: guacd
mysql:
hostname: mysql
image: mysql:5.7
volumes:
- ./tmp/scripts:/docker-entrypoint-initdb.d
restart: always
container_name: mysql
ports:
- "3306:3306"
environment:
- MYSQL_DATABASE="guacamole"
- MYSQL_USER="guacamole"
- MYSQL_PASSWORD="password"
- MYSQL_ROOT_PASSWORD="password"
guacamole:
build: .
image: mine/guacamole
restart: always
ports:
- "8443:8443"
links:
- guacd
- mysql
container_name: guacamole
environment:
- GUACD_HOSTNAME=guacd
- GUACAMOLE_HOME=/opt/guacamole-home
volumes:
tmp-scripts:
To get things started:
1) I build the guacamole image with docker build . --no-cache -t mine/guacamole
2) Start the containers and create the services by running: docker-compose up --force-recreate -d
Can someone please help?
Thanks
I made a docker-composer.yml because it's cleaner.
From these commands below:
docker run -d -v /etc/localtime:/etc/localtime:ro -v /etc/timezone:/etc/timezone:ro -e POSTGRES_USER=rundeck -e POSTGRES_PASSWORD=rundeck --name rundeck_db postgres:9.4.5
docker run --rm -ti -p 192.168.59.103:4440:4440 --link rundeck_db:db --name rundeck 3a34fdafc98a
To:
rundeck_db:
image: postgres:9.4.5
environment:
POSTGRES_USER: rundeck
POSTGRES_PASSWORD: rundeck
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
ports:
- "5432:5432"
rundeck:
build: .
ports:
- "192.168.59.103:4440:4440"
links:
- rundeck_db:db
And Dockerfile is
FROM mbopm/ubuntu-oracle-java:2.0
# install rundeck
RUN wget -O /opt/rundeck.deb http://dl.bintray.com/rundeck/rundeck-deb/rundeck-2.6.1-1-GA.deb && \
dpkg -i /opt/rundeck.deb && \
rm -rf /opt/rundeck.deb /var/lib/apt/lists/* /tmp/* /var/tmp/*
# change base configuration
RUN mkdir /etc/service/rundeck && \
mkdir /var/lib/rundeck/.ssh && \
chown -R rundeck:rundeck /var/lib/rundeck
# add init and startup scripts
ADD assets/run/rundeck.sh /etc/service/rundeck/run
ADD assets/startup/* /etc/my_init.d/
# http, https
EXPOSE 4440
# project files
# configs
# ssh-keys
# logs
VOLUME [ "/var/rundeck", "/etc/rundeck", "/var/lib/rundeck/.ssh", "/var/log/rundeck" ]
Suddenly it doesn't function. (Postgres works, but Rundeck doesn't.)
Also docker ps says
COMMAND part should be /sbin/my_init instead of /bin/sh -c ./run.sh
Any ideas?
Add
CMD [ "/sbin/my_init" ]
at the end of your dockerfile in order to change the COMMAND part
you can also add command to you docker-compose.yml file
rundeck:
build: .
command: /sbin/my_init
ports:
- "192.168.59.103:4440:4440"
links:
- rundeck_db:db