Docker Doesnot recognize already copied files to container

Hi All,

I am refering abc.sh file as the starting point of my Application Container. It comprises of some liquibase commands to populate the DB before the application started.

My docker file extract related to the issue is below.

WORKDIR /app

COPY docker-entrypoint.sh .
RUN chmod +x docker-entrypoint.sh

EXPOSE 8088

ENTRYPOINT ["/app/docker-entrypoint.sh"]

I get an error stating that docker is unable to find the .sh file which i copied.

ERROR:

*exec /app/docker-entrypoint.sh: no such file or directory *
docker-backend exited with code 1

I executed the liquibase scripts manually and changed the ENTRY point as below.

ENTRYPOINT ["java", "-jar", "my-application.jar"]

Then i can see the files are already copied inside app/ folder.

What could be the reason for this ?

I m using FROM eclipse-temurin:21-alpine image to run the java application. I m executing this docker-compose,yml file from windows OS.

STEPS i followed to run the docker container.

docker-compose up --build

Thanks in Advance.

A. Please provide the Compose file
B. If you compose the service with the entrypoint being tail -f /dev/null, then do docker exec -it <cotnainerName> ls, does it list the file?


Please, format your post according to the following guide: How to format your forum posts
In short: please, use </> button to share codes, terminal outputs, error messages or anything that can contain special characters which would be interpreted by the MarkDown filter. Use the preview feature to make sure your text is formatted as you would expect it and check your post after you have sent it so you can still fix it.

Example code block:

```
echo "I am a code."
echo "An athletic one, and I wanna run."
```

Here is my docker-compose file.

version: '3.8'

services:
  abc_postgres:
    image: postgres:15.7
    container_name: abc_postgres
    environment:
      POSTGRES_USER: MASTER_DATA
      POSTGRES_PASSWORD: xxxxx
      POSTGRES_DB: MY_DB
    ports:
      - "5433:5432"
    networks:
      - my-network
    volumes:
      - pgdata:/var/lib/postgresql/data

    healthcheck:
      test: [ "CMD-SHELL", "pg_isready -U MASTER_DATA -d MY_DB" ]
      interval: 30s
      timeout: 10s
      retries: 5


  abc-backend:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: abc-backend
    ports:
      - "8088:8088"
    environment:
      POSTGRES_HOST: abc_postgres
      POSTGRES_PORT: 5432
      POSTGRES_USER: MASTER_DATA
      POSTGRES_PASSWORD: xxxxx
      POSTGRES_DB: MY_DB
    depends_on:
      abc_postgres:
        condition: service_healthy
    networks:
      - my-network



networks:
  my-network:

volumes:
  pgdata:

Here is my docker-entrypoint.sh

#!/bin/sh

psql "postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST:$POSTGRES_PORT/$POSTGRES_DB" -f create_schema.sql

envsubst '${POSTGRES_USER} ${POSTGRES_PASSWORD} ${POSTGRES_HOST} ${POSTGRES_PORT} ${POSTGRES_DB}' < liquibase-docker.properties > liquibase.properties
liquibase/liquibase update

exec java -jar 'my-application.jar'

Since you are on Windows, check the line endings in the shell script. Having windows line endings in a shell script running on Linux can give you similar error messages. In that case the error is not that the script is not found, but the non-printable character (line endings) in the script is executed by the script.

Have you tried to execute the entrypoint manually in the container?