My Dockerfile is
FROM keymetrics/pm2:latest-alpine
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
WORKDIR /home/node/app
RUN npm install prpl-server
COPY build build/
COPY package.json .
COPY polymer.json .
COPY --chown=node:node . .
USER node
EXPOSE 8080
RUN ls -al -R
CMD [ "pm2-runtime", "start", "ecosystem.config.js", "--web"]
and my ecosystem.comfig.js is
module.exports = {
apps: [{
name: 'ozark',
script: 'npm',
args: 'start',
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: '1G',
env: {
NODE_ENV: "development",
},
env_production: {
NODE_ENV: "production",
}
}],
};
and the start script inside package.json is
"start": "cd build && prpl-server --root . --config polymer.json --port 8080 && cd ../",
to build the container im doing
polymer build && docker build -t ozark .
to start the container i do
docker run --name ozark -p 80:8080 -d ozark
but when I browse to http://locallhost nothing loads and I dont understand why.
I have viewed the logs from inside the container and the prpl server is running on port 8080
docker ps gives me...
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e7f633881e17 ozark "pm2-runtime start eā¦" 11 minutes ago Up 11 minutes 80/tcp, 443/tcp, 43554/tcp, 0.0.0.0:80->8080/tcp ozark
Related
I try to run go binary with delve use docker-compose and get an error:
ERROR: for nft-overseer Cannot start service nft-overseer: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "dlv --listen=:${dlv_port} --headless=true --api-version=2 --accept-multiclient exec ./main": stat dlv --listen=:${dlv_port} --headless=true --api-version=2 --accept-multiclient exec ./main: no such file or directory: unknown
Dockerfile (simplified)
FROM golang:1.19.1-alpine3.16 as builder
RUN apk --no-cache --update --upgrade add git alpine-sdk
ENV GO111MODULE on
ENV CGO_ENABLED 1
WORKDIR /app
COPY . .
RUN go mod download
RUN go build -gcflags "all=-N -l" ./cmd/main
FROM golang:1.19.1-alpine3.16
RUN apk --no-cache --update --upgrade add curl
RUN go install github.com/go-delve/delve/cmd/dlv#v1.20.1
ARG config_file
ARG dlv_port
WORKDIR /app
COPY configs/${config_file:-config.yaml} configs/config.yaml
COPY --from=0 /app/main .
CMD ["dlv --listen=${dlv_port} --headless=true --api-version=2 --accept-multiclient exec ./main"]
docker-compose.yml (simplified)
services:
my-service:
container_name: my-service
build:
context: .
dockerfile: ${DOCKER_FILE:-Dockerfile} # šš» Dockerfile_dlv
args:
config_file: ${CONFIG:-config.yaml}
dlv_port: ${DLV_PORT}
ports:
- "10880:8080"
- "10881:8081"
- "10882:8082"
- 10883:${DLV_PORT:-2000}
healthcheck:
test: [ "CMD", "[[ ! -z ${DLV_PORT} ]] || curl", "-f", "http://localhost:8080/health" ]
interval: 10s
timeout: 5s
retries: 3
restart: always
CONFIG=$CONFIG DLV_PORT=2000 DOCKER_FILE=Dockerfile_dlv docker-compose up --build --force-recreate -d
dlv and main exists in container
...
Step 23/28 : RUN pwd
2976 ---> Running in 1d8709c338c3
2977/app
2978Removing intermediate container 1d8709c338c3
2979 ---> 95514a03baea
2980Step 24/28 : RUN ls -l
2981 ---> Running in f65052ccf5e6
2982total 30536
2983drwxr-xr-x 2 root root 4096 Jan 13 05:57 configs
2984-rwxr-xr-x 1 root root 31261568 Jan 13 07:19 main
...
Step 25/28 : RUN dlv
2988 ---> Running in 15b54660a772
2989Delve is a source level debugger for Go programs.
2990Delve enables you to interact with your program by controlling the execution of the process,
2991evaluating variables, and providing information of thread / goroutine state, CPU register state and more.
2992The goal of this tool is to provide a simple yet powerful interface for debugging Go programs.
2993Pass flags to the program you are debugging using `--`, for example:
2994`dlv exec ./hello -- server --config conf/config.toml`
...
You need to separate the parts of the CMD:
CMD ["dlv", "--listen=${dlv_port}", "--headless=true", "--api-version=2", "--accept-multiclient", "exec", "./main"]
Right now it's looking for a file "dlv --listen=${dlv_port} --headless=true --api-version=2 --accept-multiclient exec ./main".
I have added fastapi to a docker container which does background tasks using BackgroundTask from fastapi. When i run the container the page is not loading and i have seen this error in docker desktop logs gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>. I am using docker run -d --name mycontainer -p 8080:8080 onetest to run the container.
entrypoint.sh
#!/bin/bash
gunicorn --worker-tmp-dir /dev/shm --config gunicorn.config.py app.main:app
docker file
FROM python:3.9-slim
COPY ./requirements.txt ./requirements.txt
RUN pip3 install --no-cache-dir --upgrade -r ./requirements.txt
COPY ./app ./app
COPY ./inputs ./inputs
COPY ./model ./model
COPY ./tests ./tests
COPY ./gunicorn.config.py ./gunicorn.config.py
COPY ./Procfile ./Procfile
COPY entrypoint.sh .
EXPOSE 8080
RUN chmod +x entrypoint.sh
CMD [ "./entrypoint.sh" ]
docker_config.py
bind = "0.0.0.0:8080"
workers = 4
timeout = 300
# Using Uvicorn's Gunicorn worker class
worker_class = "uvicorn.workers.UvicornWorker"
****Google Translator used****
I don't know why "ecosystem.config.js" is still included in npm agrs ...
So in the "ecosystem.config.js" file, args only has run and start, but when you build a docker, it looks like it works with npm ecosystem.config.js run start.
Please tell me why
// dockerfile
FROM node:lts-alpine
RUN npm install pm2 -g
COPY . /usr/src/nuxt/
WORKDIR /usr/src/nuxt/
RUN npm install
EXPOSE 8080
RUN npm run build
# start the app
CMD ["pm2-runtime", "ecosystem.config.js"]
// ecosystem.config.js
module.exports = {
apps: [
{
name: 'webapp',
exec_mode: 'cluster',
instances: 2,
script: 'npm',
args: ['run', 'start'],
env: {
HOST: '0.0.0.0',
PORT: 8080
},
autorestart: true,
max_memory_restart: '1G'
}
]
}
I struggled with ecosystem.config.js, I ended up using the yaml format instead: create process.yaml and enter your config>
apps:
- script: /app/index.js
name: 'app'
instances: 2
error_file: ./errors.log
exec_mode: cluster
env:
NODE_ENV: production
PORT: 12345
Then in the docker file:
COPY ./dist/index.js /app/
COPY process.yaml /app/
COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]
# Expose the listening port of your app
EXPOSE 12345
CMD [ "pm2-runtime", "/app/process.yaml"]
Just change the directories and files to the way you want things setup
The command /bin/sh -c docker login xxxx.live.dynatrace.com -u XXXX -p XXXXX returned a non-zero code: 127
I am also facing this error when i am trying to execute my default docker file.
The code is here as follows:
FROM node:10
WORKDIR /usr/src
RUN apt-get -y update
RUN docker login xxxx.live.dynatrace.com -u XXXX -p XXXXXX
COPY --from=sqx97905.live.dynatrace.com/linux/oneagent-codemodules:all / /
ENV LD_PRELOAD /opt/dynatrace/oneagent/agent/lib64/liboneagentproc.so
COPY . .
RUN npm install
EXPOSE 8080
CMD [ "node", "server.js" ]
i need to login so that i can copy the dynatrace agent so i had put the login command ahead of the COPY command. It works fine when i am logged into the terminal but i need to log into the dynatrace at run time then i am facing /bin/sh : 1 docker not found
I have the following Dockerfile (I've removed what is not relevant):
FROM centos:centos6
ENV TERM=xterm
ARG INSTALL_WKHTMLTOPDF=no
ARG WKHTMLTOPDF_VERSION=latest
ARG INSTALL_PDFTK=no
ARG PDFTK_VERSION=latest
ARG PHP_VERSION=default
...
COPY container-files /
...
EXPOSE 80 9001
WORKDIR /var/www/html
ENTRYPOINT bash -C '/entrypoint.sh';'bash'
The entrypoint.sh is as follow:
#!/bin/bash
set -e
if [ "$UID" == 0 ]; then
uid=1000;
else
uid=${UID};
fi
if [ -z "${GID}" ]; then
gid=1000;
else
gid=${GID};
fi
echo "UID: $uid"
echo "GID: $gid"
touch /var/log/xdebug.log
chown apache:root /var/log/xdebug.log
rm -f /var/run/apache2/apache2.pid
exec httpd -DFOREGROUND "$#"
And finally the docker-compose.yml file:
version: '3.4'
services:
erx:
image: arx_dev
ports:
- "80:80"
environment:
VHOST_DOCUMENT_ROOT: /var/www/html
volumes:
- ./server_logs:/var/log/:ro
After build the image and try docker-compose up -d it does not start because touch can't create the file in a RO filesystem.
PS F:\Development\docker\rx> docker logs rx_erx_1
UID: 1000
GID: 1000
touch: cannot touch `/var/log/xdebug.log': Read-only file system
PS F:\Development\docker\rx>
How I can create the file and then mount the /var/log as read only? I would like to check some logs from the host directly and avoid bash into the container. Any ideas?