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?
Related
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 would like to run hybris with the docker.
I am trying to create a docker to run hybris.
Can anyone help me with this?
This is my code:
UPDATE Question:
When I enter the container (ubuntu) and try to build hybris, there is always an error.
I created the docker-compose and the dockerfile. However, when I run ant clean all in the container the build always fails.
[![![enter image description here][1]][1]
version: '3.3'
services:
db:
image: mysql:5.6
volumes:
- //C/dockerVolumes/db_local_hybris:/var/lib/mysql
container_name: mysql_hybris
hostname: mysql_hybris
ports:
- "3307:3306"
environment:
- MYSQL_ROOT_PASSWORD=***
- MYSQL_DATABASE=***
- MYSQL_USER=***
hybris:
image: miltex/jdk:hybrisDevs
build:
context: .
container_name: hybris_dev
hostname: hybris_dev
ports:
- "8009:8009"
- "8010:8010"
- "9001:9001"
- "9002:9002"
- "1099:1099"
tty: true
links:
- db
Dockerfile
FROM miltex/jdk:1.8
#update
RUN apt-get update
## Run Initial Ant ##
RUN mkdir -p /app/hybris_dev
COPY ./hybris/HYBRISCOMM6700P_10-80003492.ZIP /app/hybris_dev/
RUN cd /app/hybris_dev && unzip HYBRISCOMM6700P_10-80003492.ZIP
#COPY ./bin/hybris-wrapper.sh /app/hybris_dev/hybris/bin/platform/
RUN mkdir /app/hybris_dev/hybris/bin/custom
COPY ./src/custom /app/hybris_dev/hybris/bin/custom
RUN cd /app/hybris_dev/installer && rm -R recipes
RUN mkdir /app/hybris_dev/installer/recipes
COPY ./src/custom/recipes /app/hybris_dev/installer/recipes
#CMD /app/hybris_dev/intaller/install.sh -r local setup ; /app/hybris_dev/hybris/bin/custom/platform/setantenv.sh ; ant clean all
## Copy hybris-wrapper to configure template properties at runtime ##
COPY ./bin/hybris-wrapper.sh /hybris-wrapper.sh
## Expose AJP S-AJP HTTP HTTPS RMI ports ##
EXPOSE 8009 8010 9001 9002 1099
RUN chmod -R 777 /app
#RUN chmod +x /hybris-wrapper.sh
# Run Hybris server
#ENTRYPOINT ["/hybris-wrapper.sh"]
[1]: https://i.stack.imgur.com/uoK3E.png
The mistake was the image I was using before. Now this dockerhub miltex:jdk:1.8 image is working perfectly.
I am attempting to expose a vue.js server running inside my docker container in a docker-compose setup. However, although I can build the individual container to do this correctly, I can't get it to work using docker-compose.
When I run the command - docker run -p 8888:8080 client (after building the client image), I'm able to access the default vue page at localhost:8888.
However, when I run docker-compose up I'm not able to do it.
Here is my docker-compose.yml -
version: '3.6'
services:
client:
restart: always
container_name: client
ports:
- "8888:8080"
environment:
- VUE_CLI_BABEL_TARGET_NODE=true
- VUE_CLI_BABEL_TRANSPILE_MODULES=true
build:
context: .
dockerfile: ./client/Dockerfile
volumes:
- "./client/:/client/"
Here is my Dockerfile -
FROM node:10-alpine
ARG PORT=8080
ENV PORT=$PORT
WORKDIR /client
RUN apk update && apk add --update bash git openssl yarn wget curl && \
rm -rf /var/cache/apk/*
COPY client /client
RUN yarn install && yarn serve
It should be noted that I am using Docker for Mac.
EDIT:
This is the output of docker container ps --no-trunc.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
049db2af69db9979c5d3feea92d7b039f6c06502f24f76ce4da75f104ff5cf60 sha256:597bb7c8dd1b3c8510b565f211873c40935a6ac9d434f9379651fab94c9f1a7d "/bin/sh -c 'yarn install && yarn serve'" 2 minutes ago Up 2 minutes agitated_stallman
d86d0c4dcc3168705f0f949876823cf4c0188161a53754788d88c20e3e42d250 sha256:b332d7c0a2af04303eac7f37f566f0451bbb222b051705d9c9e6ca8e2e97e291 "/bin/sh -c 'yarn install && yarn serve'" 3 hours ago Up 3 hours mystifying_payne
First is image, second docker-compose up. They're different.
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.