I am currently trying to set-up an instance of Open Trip Planner 2 in docker. I have created two compose files which execute the same docker image, but with different arguments.
However, currently I am having quite a lot of trouble getting the OTP JAR file to execute correctly.
I am getting the following error:
ERROR: for otp Cannot start service otp: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "otp": executable file not found in $PATH: unknown.
After a quick google search I found the
following question, but after changing the docker-compose command argument, the error still occurs.
My Dockerfile:
FROM openjdk:11
LABEL maintainer="Tristan van Triest <tristantriest#gmail.com>"
ENV OTP_VERSION=2.1.0
ADD https://repo1.maven.org/maven2/org/opentripplanner/otp/$OTP_VERSION/otp-$OTP_VERSION-shaded.jar /usr/local/share/java/
RUN ln -s otp-$OTP_VERSION-shaded.jar ./otp.jar
COPY . .
EXPOSE 8080
ENTRYPOINT [ "otp" ]
My docker-compose file:
version: '3.7'
services:
otp:
build:
context: .
dockerfile: dockerfile
restart: unless-stopped
ports:
- 9494:8080
volumes:
- ./graphs:/var/otp/graphs
environment:
- JAVA_OPTIONS=-Xmx8G
command:
[
'--maxThreads 4',
'--insecure',
'--verbose',
]
The "entrypoint" OTP file:
#!/bin/sh
exec java $JAVA_OPTIONS -jar otp.jar $#
I just simply want to be able to run the OTP Jar with different arguments. Is there an easier way to do this? Or if my current way is "correct", how can I solve the error?
Thanks,
Tristan
Related
I'm currently working on DXVKoTool, a Compose application built with Kotlin.
As I want it to be easily available on the Steam Deck, I try to build a Flatpak off it.
Basically what I wanted to do is packaging it (with jpackage) and use the built binaries when building the Flatpak.
My building process would look like this:
./gradlew packageAppImage
flatpak-builder build/release/main/flatpak dev.datlag.DXVKoTool.yml --force-clean
The packageAppImage command produces an output like this:
{project-dir}
|-build
|-release
|-main
|-app
|-DXVKoTool
|-bin
| |-DXVKoTool {executable}
|-lib
|-{resources, binaries, etc.}
However building the Flatpak is somehow driving me crazy and I'm not sure what's wrong.
My flatpak build YAML file:
app-id: dev.datlag.DXVKoTool
runtime: org.freedesktop.Platform
runtime-version: '21.08'
sdk: org.freedesktop.Sdk
command: DXVKoTool
modules:
- name: dxvkotool
buildsystem: simple
build-commands:
- mkdir -p /app/lib/
- install -Dm755 ./build/release/main/app/DXVKoTool/bin/DXVKoTool /app/bin/DXVKKoTool
- cp -R ./build/release/main/app/DXVKoTool/lib/* /app/lib/
sources:
- type: file
path: ./build/release/main/app/DXVKoTool/bin/DXVKoTool
- type: dir
path: ./build/release/main/app/DXVKoTool/lib/
When I run the flatpak-builder command, it's stopping with the following error:
Emptying app dir 'build/release/main/flatpak'
Downloading sources
Starting build of dev.datlag.DXVKoTool
Cache hit for openjdk, skipping build
Cache miss, checking out last cache hit
========================================================================
Building module git in /home/jeff/Projects/Multiplatform/DXVKoTool/.flatpak-builder/build/git-1
========================================================================
Running: mkdir -p /app/lib/
Running: install -Dm755 ./build/release/main/app/DXVKoTool/bin/DXVKoTool /app/bin/DXVKoTool
install: cannot stat './build/release/main/app/DXVKoTool/bin/DXVKoTool': No such file or directory
When I change the config to the following:
app-id: dev.datlag.DXVKoTool
runtime: org.freedesktop.Platform
runtime-version: '21.08'
sdk: org.freedesktop.Sdk
command: DXVKoTool
modules:
- name: dxvkotool
buildsystem: simple
build-commands:
- mkdir -p /app/lib/
- install -Dm755 DXVKoTool /app/bin/DXVKoTool
- cp -R lib/* /app/lib/
sources:
- type: file
path: ./build/release/main/app/DXVKoTool/bin/DXVKoTool
- type: dir
path: ./build/release/main/app/DXVKoTool/
The building works but after installing the outcome it doesn't start with this error:
bwrap: execvp DXVKoTool: No such file or directory
Would be nice if someone can help me building the Flatpak.
I have the following docker-compose file:
version: '3.1'
services:
localstack:
image: localstack/localstack:0.9.6
ports:
- "4576:4576"
environment:
- SERVICES=sqs:4576
- HOSTNAME_EXTERNAL=localhost
- DEBUG=0
- START_WEB=0
primarydb:
image: mysql:5.6
environment:
MYSQL_USER: test-user
MYSQL_PASSWORD: test-password
MYSQL_DATABASE: testdb
MYSQL_ROOT_PASSWORD: test-password
ports:
- "3318:3306"
And I have the following gradle configuration:
apply plugin: 'docker-compose'
dockerCompose.isRequiredBy(project.tasks.getByName('test'))
dockerCompose {
useComposeFiles = ['docker-compose.yml']
startedServices = ['localstack', 'primarydb']
projectName = "${rootProject.name}"
}
project.tasks.getByName('test').doFirst {
systemProperty 'localstack.sqs.endpoint', "http://localhost:4576"
systemProperty 'mysql.url', "jdbc:mysql://localhost:3318"
}
And I am using the latest docker-compose plugin: com.avast.gradle:gradle-docker-compose-plugin:0.15.1
For some reason, the build works on my friend's Linux machine, but it doesn't work on MacOS 11.4.
When I run ./gradlew composeUp task it just fails with the following error message:
./gradlew composeUp
> Configure project :
2.5.25-SNAPSHOT
> Task :composeUp
Container primarydb-1 Running
Container localstack-1 Recreate
Container localstack-1 Recreated
Container localstack-1 Starting
Container localstack-1 Started
"docker inspect" requires at least 1 argument.
See 'docker inspect --help'.
Usage: docker inspect [OPTIONS] NAME|ID [NAME|ID...]
Return low-level information on Docker objects
> Task :composeUp FAILED
...
Any idea why this plugin doesn't work on a mac but works on my friend's machine?
I faced the same error. Running ./gradle composeUp --stacktrace gave a clue what com.avast.gradle:gradle-docker-compose-plugin:0.15.1 is doing. In essence to does:
docker-compose -p <project name> up
docker-compose -p <project name> config --services and finally
docker-compose -p <project name> ps --services
The third a last step is the one which was failing on me (and is the one currently failing on you.) Repeating the compose-commands manually and having a look into the Docker Desktop UI I could see, that docker-compose did alter my project-name by removing any dots from it. After respecifying
dockerCompose {
[...]
projectName = 'name-without-dots'
}
thus ensuring that docker-compose wont alter the project name, did solve the issue for me.
Your error cause migth still be a different one. Try running ./gradlew composeUp with --stacktrace, --info or even --debug to get a better understanding of what is going wrong.
I have a Java Spring Boot app which works with a Postgres database. I want to use Docker for both of them. Initially, I created a docker-compose.yml file as given below:
version: '3.2'
services:
postgres:
restart: always
container_name: sample_db
image: postgres:10.4
ports:
- '5432:5432'
environment:
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_DB=${POSTGRES_DB}
# APP**
web:
build: .
environment:
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/test
expose:
- '8080'
ports:
- '8080:8080'
Then,inside the application.properties file I defined the following properties.
server.port=8080
spring.jpa.generate-ddl=true
spring.datasource.url=jdbc:postgresql://postgres:5432/test
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.username=root
spring.datasource.password=root
spring.flyway.baseline-on-migrate=true
spring.flyway.enabled=true
# The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
# Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto = validate
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults: true
Also,I created a Dockerfile in my project directory, which looks like this:
FROM openjdk:8-jdk-alpine
VOLUME /tmp
EXPOSE 8080
RUN mkdir -p /app/
RUN mkdir -p /app/logs/
COPY target/household-0.0.1-SNAPSHOT.jar /app/app.jar
FROM postgres
ENV POSTGRES_PASSWORD postgres
ENV POSTGRES_DB testdb
COPY schema.sql /docker-entrypoint-initdb.d/
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app/app.jar"]
I issued these commands and ended up in the error as given below.
mvn clean package
docker build ./ -t springbootapp
docker-compose up
ERROR: for household-appliances_web_1 Cannot start service web: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"java\": executable file not found in $PATH": unknown
ERROR: for web Cannot start service web: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"java\": executable file not found in $PATH": unknown
ERROR: Encountered errors while bringing up the project.
Kindly anyone help on this!
I had this error when setting up a Rails appliation for Docker:
My docker-entrypoint.sh file was placed in the root folder of my application with this content:
#!/bin/sh
set -e
bundle exec rails server -b 0.0.0.0 -e production
And in my Dockerfile, I defined my entrypoint command this way:
RUN ["chmod", "+x", "docker-entrypoint.sh"]
ENTRYPOINT ["docker-entrypoint.sh"]
But I was getting the error below when I ran the docker-compose up command:
ERROR: for app Cannot start service app: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: "docker-entrypoint.sh": executable file not found in $
PATH": unknown
Here's how I fixed it:
Specify an actual path for the docker-entrypoint.sh file, that is instead of:
ENTRYPOINT ["docker-entrypoint.sh"]
use
ENTRYPOINT ["./docker-entrypoint.sh"]
This tells docker that the docker-entrypoint.sh file is located in the root folder of your application, you could also specify a different path if the path to your docker-entrypoint.sh is different, but ensure you do not miss out on the ./ prefix to your docker-entrypoint.sh file path definition.
So mine looked like this afterwards:
RUN ["chmod", "+x", "docker-entrypoint.sh"]
ENTRYPOINT ["./docker-entrypoint.sh"]
That's all.
I hope this helps
application.properties file content is irrelevant to question, so you can remove it.
Lets look to your Dockerfile, I will remove irrelevant code
FROM openjdk:8-jdk-alpine
COPY target/household-0.0.1-SNAPSHOT.jar /app/app.jar
FROM postgres
COPY schema.sql /docker-entrypoint-initdb.d/
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app/app.jar"]
So you are using multistage building, you just copying file from host to first stage.
As final stage you are using postgres image and telling to set ENTRYPOINT to java, but java does not exists in the postgres image.
What you should change:
You should have postgres containe separated from java container like you have it in docker-compose.yml file and second suggestion use CMD instead of ENTRYPOINT.
Your final Dockerfile should be
FROM openjdk:8-jdk-alpine
COPY target/household-0.0.1-SNAPSHOT.jar /app/app.jar
CMD ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app/app.jar"]
The FROM postgres line creates a second image (it is a multi-stage build) that is based on the PostgreSQL database server. Everything above that line is effectively ignored. So your final image is running a second database, and not a JVM.
You don't need this line, and you don't need to extend the database server to run a client. You can delete this line, and the application will start up.
You'll also have to separately get that schema file into the database container. Just bind-mounting the file in volumes: in the docker-compose.yml file is an easy path. If you have a database migration system in your application, running migrations on startup will be a more robust approach.
I used Docker for Selenium Grid Hub and Nodes to collect data, including
selenium/hub: 3.141.59-iron
selenium/node-fire_fox 3.141.59-iron
but one day after running, selenium-hub hung the following exception:
INFO exited: selenium-hub (exit status 137; not expected)
selenium/node-fire_fox exception is:
INFO [SelfRegisteringRemote$1.run] - Couldn't register this node: The hub is down or not responding: Failed to connect to selenium-hub/172.24.0.2:4444
What should I do?
This is not a problem related to Selenium, but an issue with Docker.
The following link has a summary of root causes for the error exit status 137; not expected:
https://success.docker.com/article/what-causes-a-container-to-exit-with-code-137
In short, for some reason, Docker is killing the process, in your case, selenium-hub.
For Mac and Windows, you probably need to increase the memory dedicated to Docker in Docker preferences.
This answer here on SO has a screenshot showing how to do it.
if you are using docker I dont understand why are you leaving you hub up and running .
checkout their hub page : https://github.com/SeleniumHQ/docker-selenium/tree/master/Hub
hub launch : docker run -d -p 4444:4444 --name selenium-hub selenium/hub
nodes launch :
$ docker run -d --link selenium-hub:hub -v /dev/shm:/dev/shm selenium/node-chrome
$ docker run -d --link selenium-hub:hub -v /dev/shm:/dev/shm selenium/node-firefox
I would write a pipeline and define my hubimage and node images which I bring up at the beginning of the test session and remove the images at the end of the session.
try{
hubimage
nodeimage
runtests
} catch(anything){
throw anything;
} finally {
sh "docker rmi \$(docker inspect --format='{{range .RepoTags}} {{.}} {{end}}' ${hubimage});"
sh "docker rmi \$(docker inspect --format='{{range .RepoTags}} {{.}} {{end}}' ${nodeimage});"
}
see more informations about pipelines : https://jenkins.io/doc/book/pipeline/
In my docker-compose.yaml file I use the image "my-service" (among other remote images that work fine)
version: "2"
services:
myservice:
image: my-service
Normally I build the "my-service" image with maven using the io.fabric8 docker-maven-plugin.
My Dockerfile:
FROM vertx/vertx3-alpine
ENV VERTICLE_HOME /opt/lib
ENV NAME my-service
ENV EXEC_JAR_NAME my-service.jar
COPY target/my-service-1.0-SNAPSHOT.jar $VERTICLE_HOME/$EXEC_JAR_NAME
COPY target/lib $VERTICLE_HOME
COPY src/main/resources/settings.json /etc/company/myservice/settings.json
ENTRYPOINT ["sh", "-c"]
CMD ["java -cp $VERTICLE_HOME/$EXEC_JAR_NAME com.company.myservice.MyVerticle"]
Is there a way using the DockerComposeContainer from Testcontainers for docker-compose to use my local image of my-service?
This is my test set up
public class MyServiceIT {
#ClassRule
public static DockerComposeContainer compose =
new DockerComposeContainer(new File("src/test/resources/docker-compose.yml"));
Currently I get the following error message as it is using local images.
7:15:34.282 [tc-okhttp-stream-454305524] INFO 🐳 [docker/compose:1.8.0] - STDERR: pull access denied for my-service, repository does not exist or may require 'docker login'
17:15:34.283 [main] WARN org.testcontainers.containers.DockerComposeContainer - Exception while pulling images, using local images if available
It sounds like I need to build the image for use in my test, but I am not sure how to do that.
That's not an error message, but just a warning if docker-compose pull fails, see here.
You can also make Docker Compose build the images for you (although it is highly recommended to use withLocalCompose(true) in that case)