Getting error Error response from daemon: failed to create shim task: OCI runtime create failed (permission denied: unknown), while creating container

490 views Asked by At

I'm using Intellij Idea to create an image using docker plugin (sbt-native-packager).

Creating an Image by Running the command in sbt-shell.

sbt> docker:publishlocal

The Image created successfully(checking by using docker images)

student                0.0.3     aecb0ddf2593   12 minutes ago   662MB

The docker file created automatically by sbt-native-packager is:

FROM openjdk:8
USER root
RUN id -u demiourgos728 1>/dev/null 2>&1 || (( getent group 0 1>/dev/null 2>&1 || ( type groupadd 1>/dev/null 2>&1 && groupadd -g 0 root || addgroup -g 0 -S root )) && ( type useradd 1>/dev/null 2>&1 && useradd --system --create-home --uid 1001 --gid 0 demiourgos728 || adduser -S -u 1001 -G root demiourgos728 ))
WORKDIR /opt/docker
COPY --chown=demiourgos728:root opt /opt
EXPOSE 8083
USER 1001:0
ENTRYPOINT ["/opt/docker/bin/student"]
CMD []

Now I want to run this image in a docker container using docker compose version 3

student-docker.yml

version: "3"

services:

student-database-container:
    container_name: student-container
    image: student:0.0.3
    ports:
      - 8083:8083
    networks:
     - web

networks:
  web:
    driver: bridge

The issue occurred when I run the command

docker compose -f student-docker.yml up

It generate an error:

[+] Running 1/0
 ✔ Container student-container  Created                                                                                                           0.1s 
Attaching to student-container
Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: eaccess /opt/docker/bin/student: permission denied: unknown

When I run command 'docker ps -a'

aecb0ddf2593   student:0.0.3                "/opt/docker/bin/stu…"   12 minutes ago   Created                      0.0.0.0:8083->8083/tcp, :::8083->8083/tcp   student-container

Updated:

Here is my build.sbt

import com.typesafe.sbt.packager.docker.{Cmd, DockerChmodType, DockerPermissionStrategy, ExecCmd}

lazy val root = (project in file("."))
  .settings(
    name := "student"
  )

ThisBuild / version := "0.1.0-SNAPSHOT"

ThisBuild / scalaVersion := "2.13.1"

enablePlugins(JavaAppPackaging, DockerPlugin)
packageName in Docker:= "student"

version in Docker:= "0.0.1"
dockerExposedPorts:= Seq(8083)

dockerChmodType := DockerChmodType.UserGroupWriteExecute
dockerPermissionStrategy := DockerPermissionStrategy.CopyChown
dockerAdditionalPermissions += (DockerChmodType.UserGroupPlusExecute, "/var/run/")

libraryDependencies ++= Seq(
  "com.typesafe" % "config" % "1.3.0",
  "com.typesafe.akka" %% "akka-actor" % "2.6.0",
  "com.typesafe.akka" %% "akka-stream" % "2.7.0",
  "com.typesafe.akka" %% "akka-http" % "10.5.0",
  "ch.qos.logback" % "logback-classic" % "1.3.5"
)

When I remove the following lines from build.sbt,

dockerChmodType := DockerChmodType.UserGroupWriteExecute
    dockerPermissionStrategy := DockerPermissionStrategy.CopyChown
    dockerAdditionalPermissions += (DockerChmodType.UserGroupPlusExecute, "/var/run/")

the container runs successfully.

Help me to resolve this error.

Thank you.

0

There are 0 answers