Running the following cmd:
docker-compose up -d
Throws the following error:
ERROR: for ubuntu_caddy_1 Cannot start service caddy: oci runtime error: container_linux.go:247: starting container process caused "exec: \"./caddy\": stat ./caddy: no such file or directory"
Here is docker-compose.yml file
services:
caddy:
image: abiosoft/caddy
ports:
- "80:80"
- "443:443"
- "2015:2015"
volumes:
- "./caddy-data:/root/.caddy"
- "./config:/etc/caddy"
- "./config/Caddyfile:/etc/Caddyfile"
entrypoint:
- ./caddy
- "-conf"
- /etc/Caddyfile
- "-agree"
- "-log=stdout"
- "-port=443"
restart: "on-failure: 10"
user: root
version: "2"
Any idea on what I would be missing here?
In the abiosoft/caddy Dockerfile, the standard entrypoint is ENTRYPOINT ["/bin/parent", "caddy"] (link here).
So I think that you must change ./caddy in your entrypoint by /bin/parent caddy.
I also think that you don't have to overwrite the default entrypoint, you just have to specify your args to caddy by overwriting the default command (which is CMD ["--conf", "/etc/Caddyfile", "--log", "stdout", "--agree=$ACME_AGREE"]).
So you end up with command: -conf /etc/Caddyfile -agree -log=stdout -port=443.
Related
I want to run a docker-compose file but I keep getting
ERROR: for service2 Cannot start service service2: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "./wait.sh": stat ./wait.sh: no such file or directory: unknown
and my docker-compose file is
version: "3"
services:
service1:
restart: always
container_name: service1
build: ./service1
environment:
- POSTGRES_DB
- POSTGRES_USER
- POSTGRES_PASSWORD
service2:
container_name: service2
build: ./service2
environment:
- POSTGRES_DB
- POSTGRES_USER
- POSTGRES_PASSWORD
depends_on:
- service1
restart: "no"
volumes:
- ./data.csv:/data.csv
command: ["./wait.sh", "service1:5432", "--", "python", "./service2.py"]
but if I go and try to build Dockerfile for service2 everything is ok and I can run wait.sh.
Here's Dockerfile for service2:
FROM python:latest
WORKDIR /service2
RUN pip install psycopg2==2.8.6
COPY ./service2.py .
COPY ./wait.sh ./wait.sh
RUN chmod +x ./wait.sh
I completely don't get what's wrong especially because when I first ran docker-compose up the same error occured. But after that error did not occur for several times I ran docker-compose up and now again it doesn't work though I run the same docker-compose file.
wait.sh was taken from here
service2.py connects to db and writes from data.scv but since it doesn't even run that should not be the problem.
I am trying to run my restful api in docker but having issue with my golang executable it is always not found. Here is my Dockerfile
# Start from golang base image
FROM golang:1.15.2
#Set ENV
ENV DB_HOST=fullstack-mysql \
DB_DRIVER=mysql \
DB_USER=root \
DB_PASSWORD=root \
DB_NAME=link_aja \
DB_PORT=3306 \
APP_NAME=golang-linkaja \
CGO_ENABLED=0
# Copy the source from the current directory to the working Directory inside the container
COPY . /usr/src/${APP_NAME}
# Move to working directory
WORKDIR /usr/src/${APP_NAME}
#install depedencies
RUN go mod download
# Build the application
RUN go build -o ${APP_NAME}
# Expose port 3000 to the outside world
EXPOSE 3000
#Command to run the executable
CMD ${APP_NAME}
And here is my docker-compose.yml
version: '3'
services:
app:
container_name: golang-linkaja
build: .
ports:
- 3000:3000
restart: on-failure
volumes:
- api:/usr/src/${APP_NAME}
depends_on:
- fullstack-mysql
networks:
- fullstack
fullstack-mysql:
image: mysql:5.7
container_name: full_db_mysql
ports:
- 3306:3306
environment:
- MYSQL_ROOT_HOST=${DB_HOST}
- MYSQL_USER=${DB_USER}
- MYSQL_PASSWORD=${DB_PASSWORD}
- MYSQL_DATABASE=${DB_NAME}
- MYSQL_ROOT_PASSWORD=${DB_PASSWORD}
volumes:
- database_mysql:/var/lib/mysql
networks:
- fullstack
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin_container
depends_on:
- fullstack-mysql
environment:
- PMA_HOST=fullstack-mysql #DB_HOST env must be the same with this
- PMA_USER=${DB_USER}
- PMA_PORT=${DB_PORT}
- PMA_PASSWORD=${DB_PASSWORD}
ports:
- 9090:80
restart: always
networks:
- fullstack
volumes:
api:
database_mysql:
# Networks to be created to facilitate communication between containers
networks:
fullstack:
driver: bridge
Everything works correctly except for the Go app itself, here is the error that I get
golang-linkaja | /bin/sh: 1: golang-linkaja: not found
Could i get any help please? i'm new and still learning docker
Thanks in advance!
Update: here are the other things i've tried:
1.Changing CMD to CMD ["./usr/src/${APP_NAME}/${APP_NAME}"]
Return error golang-linkaja | sh: 1: /usr/src/golang-linkaja/golang-linkaja: not found
2.Changing to CMD [ "./golang-linkaja" ] and CMD [ "./${APP_NAME}" ]
Return error ERROR: for golang-linkaja Cannot start service app: OCI runtime create failed: container_linux.go:370: starting container process caused: exec: "./golang-linkaja": stat ./golang-linkaja: no such file or directory: unknown
You need to remove the volume - api:/usr/src/${APP_NAME} from your compose. You have already copied what you need in your Dockerfile. The volume(defined in compose) is overwriting all your data and hence your built binary is not found.
Just remove the volume and try to rebuild and start the container again .... and change your cmd to CMD [ "./${APP_NAME}" ]
In your Dockerfile, you try to run your executables without using ./ prefix, So OS search executable on system folders and can not find it. Add ./ beginning of your CMD or use the absolute path of the executable.
#Command to run the executable
CMD ./${APP_NAME}
or
#Command to run the executable
CMD /usr/src/${APP_NAME}
I created machine:
docker-machine create -v virtualbox docker-local
Switched to machine:
eval ($docker-machine env docker-local)
Now, Im trying to run docker-compose on it to serve my apps on this machine.
This are my files:
docker-compose.yml
version: "3"
services:
db:
image: mysql:5.7
container_name: db
ports:
- '3306:3306'
environment:
MYSQL_DATABASE: 'test'
MYSQL_ROOT_PASSWORD: 'asdasd123'
command: ['mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci']
app:
build:
context: .
dockerfile: ./dockerfiles/python/Dockerfile
container_name: app
volumes:
- ./app:/app
- static:/app/static
- media:/app/media
command: >
./wait-for-it.sh db:3306 --timeout=30 --strict -- ./run.sh
expose:
- "8000"
depends_on:
- db
nginx:
container_name: nginx
restart: always
build:
context: .
dockerfile: ./dockerfiles/nginx/Dockerfile
volumes:
- ./nginx:/etc/nginx/conf.d
- ./nginx_logs:/var/log/nginx
- ./nginx_html:/html
- ./ssl_cert:/etc/nginx/conf.d/certs/
- static:/static
- media:/media
ports:
- "1337:80"
- "443:443"
depends_on:
- app
volumes:
static:
media:
If i lauch this docker-compose.yml using docker-compose up everything works fine in local pc, however on virtualbox machine - error accured:
Creating db ... done
Creating app ... error
ERROR: for app Cannot start service app: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \"./wait-for-it.sh\": stat ./wait-for-it.sh: no such file or directory": unknown
ERROR: for app Cannot start service app: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \"./wait-for-it.sh\": stat ./wait-for-it.sh: no such file or directory": unknown
ERROR: Encountered errors while bringing up the project.
Why is this happening only on docker-machine? Why it has no access to wait-for-it.sh here?
I'm trying to use wait-for-it in my docker-compose.yaml to wait for mysql to be ready before creating services that are dependent on it. This is my docker-compose.yaml:
version: '3.5'
services:
mysql:
image: mysql:5.6
ports:
- "3307:3306"
networks:
- integration-tests
environment:
- MYSQL_DATABASE=mydb
- MYSQL_USER=root
- MYSQL_ROOT_PASSWORD=mypassword
entrypoint: ./wait-for-it.sh mysql:3306
networks:
integration-tests:
name: integration-tests
I get this error when trying to run this with docker-compose:
Starting integration-tests_mysql_1 ... error
ERROR: for integration-tests_mysql_1 Cannot start service mysql: OCI
runtime create failed: container_linux.go:348: starting container
process caused "exec: \"./wait-for-it.sh\": stat ./wait-for-it.sh: no
such file or directory": unknown
ERROR: for mysql Cannot start service mysql: OCI runtime create
failed: container_linux.go:348: starting container process caused
"exec: \"./wait-for-it.sh\": stat ./wait-for-it.sh: no such file or
directory": unknown ERROR: Encountered errors while bringing up the
project.
The wait-for-it.sh script is there on the same level as my docker-compose.yaml file so I don't understand why it's not being found.
Your issue here is that you're trying to execute something that is not part of your image. You're telling docker to create a container from mysql:5.6, which doesn't contain wait-for-it.sh, and then you're telling it to start the container by launching wait-for-it.sh.
I would recommend that you create your own image containing the following:
#Dockerfile
FROM mysql:5.6
COPY wait-for-it.sh /wait-for-it.sh
RUN chmod +x /wait-for-it.sh
Then you would replace mysql:5.6 with your image and you should be able to execute wait-for-it.sh. I would also execute it through a command instead of an entrypoint as such:
#docker-compose.yml
...
mysql:
image: yourmysql:5.6
command: bash -c "/wait-for-it.sh -t 0 mysql:3306"
...
Where -t 0 will wait for mysql without a timeout.
You can control services startup order by using the docker depends_on option.
I have the following docker-compose file:
version: '3'
services:
frontend:
image: node:9
working_dir: /dist
command: PORT=8000 node /static/index.js
volumes:
- ./dist:/static
ports:
- "8000:8000"
environment:
NODE_ENV: ${NODE_ENV}
But when I run it, I get this error:
Cannot start service frontend: OCI runtime create failed:
container_linux.go:296: starting container process caused "exec:
\"PORT=8000\": executable file not found in $PATH": unknown
You don't need the command to publish the port or make accessible by the host.
Only clause ports is enough.
ports:
- 8000:8000
note the double quote.
If you need a environment variable, can use the clause environment
frontend:
environment:
- PORT=8000