Pushing docker image in AWS ECR from SageMaker Studio using AWS CLI - amazon-sagemaker

We can now publish Docker images to AWS ECR directly from SageMaker Studio using this code https://github.com/aws-samples/sagemaker-studio-image-build-cli
I did follow the easy installation instructions:
!pip install sagemaker-studio-image-build
sm-docker build .
Also Trust policy and permissions have been set as described in the instructions.
But I'm getting the error "Command did not exit successfully docker push" at the stage where it is pushing the Docker image to AWS ECR. Any idea why? Here are the details print as output:
[Container] 2021/05/04 06:57:20 Running command echo Pushing the Docker image...
Pushing the Docker image...
[Container] 2021/05/04 06:57:20 Running command docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG
The push refers to repository [752731038471.dkr.ecr.eu-central-1.amazonaws.com/sagemaker-studio-d-tfbogtriaiml]
An image does not exist locally with the tag: 752731038471.dkr.ecr.eu-central-1.amazonaws.com/sagemaker-studio-d-tfbogtriaiml
[Container] 2021/05/04 06:57:20 Command did not exit successfully docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG exit status 1
[Container] 2021/05/04 06:57:20 Phase complete: POST_BUILD State: FAILED
[Container] 2021/05/04 06:57:20 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG. Reason: exit status 1

In the Dockerfile, there was a reference to another file that was not present in the directory from where the command sm-docker build . was launched.

Related

Unable to go inside a running docker container

I am using ubuntu 22.04 lts as a sudo user.
I made a react application and then I created a image and ran it in a container successfully. But i want to go inside the container for which i ran the below command:
docker exec -it e448b7024af bash
but i got the following error:
Error response from daemon: Container e448b7024af19a0bb is not running
I ran the below command to check if container is running:
docker ps
// i got my container in the list
// also i did some actions in react application to double check if conatiner was working and it worked perfectly
below is the output for the above command:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
56f8042d2f1 react_d "docker-entrypoint.s…" 12 minutes ago Up 12 minutes 0.0.0.0:3000->3000/tcp, :::3000->3000/tcp youthful_sammet
then based on some other solution i tried the below command:
docker run -it e448b7024af /bin/bash
and i got the following error:
Unable to find image 'e448b7024af:latest' locally
docker: Error response from daemon: pull access denied for e448b70254af, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
See 'docker run --help'.
then i tried the following command based on some solution i found:
docker pull e448b7024af:latest
but i got the following error:
Error response from daemon: pull access denied for e448b7024af, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
i also tried:
docker exec -it 568f8042d2f1 bash
and i got the following error:
OCI runtime exec failed: exec failed: unable to start container process: exec: "bash": executable file not found in $PATH: unknown
Below is my Dockerfile:
FROM node:alpine
WORKDIR /app
COPY /package*.json ./
RUN npm install
COPY . .
CMD ["npm","run","start"]
My container is working properly but i am unable to get inside of the container. Any help is appreciated. Thanks in advance.
Based on the output from docker ps, your container id is 56f8042d2f1 and not e448b7024af which I suspect might be your image id or a container id from a previous run.
Another thing is that bash isn't installed in Alpine images by default. You can use sh instead.
You can use the more human-friendly container name of youthful_sammet in your command and do
docker exec -it youthful_sammet sh
or, if you prefer the id
docker exec -it 56f8042d2f1 sh
you are using the wrong container identifier in the docker exec command as when you do docker ps the container id is different and you are using the wrong one.
I personally use the container name as identifier it is easy to remember.

Is it possible to create custom Linux-based Docker image on Azure Windows Server DSVM

I am using an Azure DSVM in a DevTest Lab running Windows Server 2019. I am trying to get Docker installed and working to allow me to run local experiments from Azure ML Service environments.
I want to build a custom Linux container on Docker - which I believe is possible on Windows from reading some other online posts (I can't use a Linux host for various reasons). When I try to create such an image that contains a WORKDIR ... step, I get a "container ***** encountered an error during CreateProcess: failure in a Windows system call" error.
I installed Docker on the DSVM (which is a Standard D2s_v3) by adding the "Docker" artifact at creation and then running the following commands to enable Linux containers:
$> Install-WindowsFeature -Name Hyper-V -IncludeManagementTools -Restart
$> [Environment]::SetEnvironmentVariable("LCOW_SUPPORTED", "1", "Machine")
Running a simple Linux container works fine:
$> docker run --rm -it alpine:latest
/ # ls
bin dev etc home lib media mnt opt proc root run sbin srv sys tmp usr var
/ #
To build a custom image, I'm using a simple Dockerfile as follows:
FROM alpine:latest
WORKDIR /abm
The image appears to build successfully:
$> docker build --no-cache -t abm-alpine:workdir -f .\abm-alpine.Dockerfile .
Sending build context to Docker daemon 2.048kB
Step 1/2 : FROM alpine:latest
---> a187dde48cd2
Step 2/2 : WORKDIR /abm
---> 495f8ecb3a0e
Removing intermediate container 219e91296e47
Successfully built 495f8ecb3a0e
Successfully tagged abm-alpine:workdir
When I run the image, I get the following error:
$> docker run --rm -it abm-alpine:workdir
C:\Program Files\Docker\docker.exe: Error response from daemon: container 01fad57c971d672d91238a6c6ec21376e033006ec4c26563e91e7288cfb3bfeb encountered an error during CreateProcess: failure in a Windows system call: The virtual machine or container exited unexpectedly. (0xc0370106) extra info: {"CommandArgs":["/bin/sh"],"WorkingDirectory":"/abm","Environment":{"HOSTNAME":"01fad57c971d","PATH":"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","TERM":"xterm"},"EmulateConsole":true,"CreateStdInPipe":true,"CreateStdOutPipe":true,"ConsoleSize":[50,120],"OCISpecification":{"ociVersion":"1.0.0","process":{"terminal":true,"consoleSize":{"height":50,"width":120},"user":{"uid":0,"gid":0},"args":["/bin/sh"],"env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin","HOSTNAME=01fad57c971d","TERM=xterm"],"cwd":"/abm","capabilities":{"bounding":["CAP_CHOWN","CAP_DAC_OVERRIDE","CAP_FSETID","CAP_FOWNER","CAP_MKNOD","CAP_NET_RAW","CAP_SETGID","CAP_SETUID","CAP_SETFCAP","CAP_SETPCAP","CAP_NET_BIND_SERVICE","CAP_SYS_CHROOT","CAP_KILL","CAP_AUDIT_WRITE"],"effective":["CAP_CHOWN","CAP_DAC_OVERRIDE","CAP_FSETID","CAP_FOWNER","CAP_MKNOD","CAP_NET_RAW","CAP_SETGID","CAP_SETUID","CAP_SETFCAP","CAP_SETPCAP","CAP_NET_BIND_SERVICE","CAP_SYS_CHROOT","CAP_KILL","CAP_AUDIT_WRITE"],"inheritable":["CAP_CHOWN","CAP_DAC_OVERRIDE","CAP_FSETID","CAP_FOWNER","CAP_MKNOD","CAP_NET_RAW","CAP_SETGID","CAP_SETUID","CAP_SETFCAP","CAP_SETPCAP","CAP_NET_BIND_SERVICE","CAP_SYS_CHROOT","CAP_KILL","CAP_AUDIT_WRITE"],"permitted":["CAP_CHOWN","CAP_DAC_OVERRIDE","CAP_FSETID","CAP_FOWNER","CAP_MKNOD","CAP_NET_RAW","CAP_SETGID","CAP_SETUID","CAP_SETFCAP","CAP_SETPCAP","CAP_NET_BIND_SERVICE","CAP_SYS_CHROOT","CAP_KILL","CAP_AUDIT_WRITE"]}},"root":{"path":"rootfs"},"hostname":"01fad57c971d","mounts":[{"destination":"/proc","type":"proc","source":"proc","options":["nosuid","noexec","nodev"]},{"destination":"/dev","type":"tmpfs","source":"tmpfs","options":["nosuid","strictatime","mode=755","size=65536k"]},{"destination":"/dev/pts","type":"devpts","source":"devpts","options":["nosuid","noexec","newinstance","ptmxmode=0666","mode=0620","gid=5"]},{"destination":"/sys","type":"sysfs","source":"sysfs","options":["nosuid","noexec","nodev","ro"]},{"destination":"/sys/fs/cgroup","type":"cgroup","source":"cgroup","options":["ro","nosuid","noexec","nodev"]},{"destination":"/dev/mqueue","type":"mqueue","source":"mqueue","options":["nosuid","noexec","nodev"]},{"destination":"/dev/shm","type":"tmpfs","source":"shm","options":["nosuid","noexec","nodev","mode=1777"]}],"linux":{"resources":{"devices":[{"allow":false,"access":"rwm"},{"allow":true,"type":"c","major":1,"minor":5,"access":"rwm"},{"allow":true,"type":"c","major":1,"minor":3,"access":"rwm"},{"allow":true,"type":"c","major":1,"minor":9,"access":"rwm"},{"allow":true,"type":"c","major":1,"minor":8,"access":"rwm"},{"allow":true,"type":"c","major":5,"minor":0,"access":"rwm"},{"allow":true,"type":"c","major":5,"minor":1,"access":"rwm"},{"allow":false,"type":"c","major":10,"minor":229,"access":"rwm"}]},"namespaces":[{"type":"mount"},{"type":"network"},{"type":"uts"},{"type":"pid"},{"type":"ipc"}],"maskedPaths":["/proc/kcore","/proc/latency_stats","/proc/timer_list","/proc/timer_stats","/proc/sched_debug"],"readonlyPaths":["/proc/asound","/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]},"windows":{"layerFolders":["C:\\ProgramData\\docker\\lcow\\5ba6a7b4fbdf9748ec89898be9bdaa911ee614436a475945638ab296b1155966","C:\\ProgramData\\docker\\lcow\\01fad57c971d672d91238a6c6ec21376e033006ec4c26563e91e7288cfb3bfeb"],"hyperv":{},"network":{"endpointList":["D615E3D5-B6AA-401E-A0A0-72581FA47059"],"allowUnqualifiedDNSQuery":true}}}}.
I've tried various logs (e.g. Get-WinEvent -LogName Microsoft-Windows-Hyper-V-Compute-Operational and Get-EventLog -LogName Application -Source Docker) but cannot see any additional information about the error.
Can anyone advise if it is possible to create custom Linux-based images on a Windows DSVM? If it is, can anyone advise what the problem may be or any additional troubleshooting steps I could take?
Thanks!
It is possible to create Linux container on Windows Server.
Although this is currently in experimental stage.
This article might help : https://www.b2-4ac.com/lcow-linux-containers-on-windows-server/

Why don't I get access to the React application inside Docker?

I executed npm run build and created a react build then I build a Docker image with the Docker file.
FROM node:12.2.0-alpine
COPY build ./
RUN ["npm", "install", "-g", "serve"]
CMD ["serve", "-s", "build"]
I run this docker image with the command:
docker run -ip 5000:5000 steinko/testreacttutorial:1
Then I got the message:
INFO: Accepting connections at http://localhost:5000
When I enter localhost:5000 in the browser I get the following:
404 Request path could not be found
How do I fix this error?
please check the docker inspect command output for your image to find the application port exposed and then map that to 5000 port in the docker run command

Build the docker with react app throws error

Create the scratch react application using "create-react-app docker-build" then try to build the docker image for it with below docker script but it throws error when try to run that docker image.
Docker version have used: Docker version 18.09.0, build 4d60db4
Simply follow the steps in below post for docker exploration with react app but i end up with error like below
Reference : https://medium.com/#shakyShane/lets-talk-about-docker-artifacts-27454560384f
Step 1:
Build the docker image success.
docker build -t testwebapp .
Step 2:
Run the that image with below command
docker run -p 8080:80 testwebapp:latest
Docker script used:
FROM node:10.9 as build-deps
WORKDIR /usr/src/app
COPY package.json yarn.lock ./
RUN yarn
COPY . ./
RUN yarn build
FROM nginx:1.12-alpine
COPY - from=build-deps /usr/src/app/build /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Error log:
docker: Error response from daemon: driver failed programming external connectivity on endpoint festive_margulis (71686edb7753ec2fdf019ef4cfcf0e95476e1fb7c2368084feb17fd2551fcf45): Error starting userland proxy: mkdir /port/tcp:0.0.0.0:8080:tcp:172.17.0.3:80: input/output error.
Usually, this is a problem with the Docker engine.
service docker restart
If you are working with Windows you have to specify the ip address like
docker run -ip 127.0.0.1 -p 8080:80 testwebapp:latest
And usually for me i have to restart the docker on windows after pc start twice then works everything as it should

docker executable file not found in $PATH" react image

I am trying to run a freshly create react app made with create-react-app in docker. I have a Docker file which succesfully allows me to build the image, but when I try to run it I get:
PS C:\Users\Bertinator\desktop\gamelist\client> docker run client4 .
container_linux.go:265: starting container process caused "exec: \".\":
executable file not found in $PATH"
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from
daemon: oci runtime error: container_linux.go:265: starting container
process caused "exec: \".\": executable file not found in $PATH".
ERRO[0001] error waiting for container: context canceled
PS C:\Users\Bertinator\desktop\gamelist\client>
This is my Docker file, which is place in the root folder of my create-react-app project:
FROM node:7.8.0
ENV NPM_CONFIG_LOGLEVEL warn
COPY . .
RUN npm run build --production
RUN npm install -g serve
CMD serve -s build
EXPOSE 5000
Are you running from a Linux docker image on a Windows machine? That does not work.
Ref http://training.play-with-docker.com/beginner-linux/
(...) Linux containers require the Docker host to be running a Linux kernel. For example, Linux containers cannot run directly on Windows Docker hosts. The same is true of Windows containers - they need to run on a Docker host with a Windows kernel.
When you say docker run client4 . you are asking docker to run that container and execute the . (dot) command which does not make sense. That is why you are getting the first error.

Resources