I am trying to build a dockerfile for a Euler App to test ShinyProxy via "http://www.shinyproxy.io/deploying-apps/"
I am using the dockerfile from that link.
Upon using the command sudo docker build -t openanalytics/shinyproxy-template .
I get an error while the build is processing that:
Error: unexpected end of input
Execution halted
The command '/bin/sh -c R -e "install.packages(c('shiny', 'rmarkdown', repos='https://cloud.r-project.org/')" ' returned a non-zero code: 1.
I am curious why I am getting this error as this is the same exact command from the dockerfile.
What can I do to resolve this.
-Thanks
Look closely at the syntax of the R install library line and you will see its missing a closing parenthesis
I just manually fixed that syntax and it correctly builds that step
correct syntax
RUN R -e "install.packages(c('shiny', 'rmarkdown'), repos='https://cloud.r-project.org/')"
build it as
docker build --tag r_base .
NOTE - as docker build progresses it then fails later attempting to
COPY euler /root/euler
lstat euler: no such file or directory
To troubleshot this just comment out all Dockefile lines from offending onward and replace bottom line with
CMD ["/bin/bash"]
then it will build correctly and allow you to login to running container to further troubleshoot
docker run -ti r_base bash
I know nothing of R so will leave it to the reader to fix euler COPY ... evidently you must have euler sitting in your local directory prior to issuing the docker build command
...now after you issue above docker run command then from its internal to container prompt issue
cd /
find . | grep Rprofile.site
./usr/lib/R/etc/Rprofile.site
That looks good so leave commented out its COPY in Dockerfile
Related
I am trying to build my dockerfile as shown thus:
ARG IMG_TAG=latest
# Compile the gaiad binary
FROM golang:1.18-alpine AS gaiad-builder
WORKDIR /usr/src/app
COPY go.mod go.sum* ./
RUN go mod download
COPY . .
ENV PACKAGES curl make git libc-dev bash gcc linux-headers eudev-dev python3
RUN apk add --no-cache $PACKAGES
RUN CGO_ENABLED=0 make install
# Add to a distroless container
FROM distroless.dev/static:$IMG_TAG
ARG IMG_TAG
COPY --from=gaiad-builder /go/bin/gaiad /bin
RUN gaiad init Edima
# && wget https://raw.githubusercontent.com/cosmos/mainnet/master/genesis/genesis.cosmoshub-4.json.gz \
# && gzip -d genesis.cosmoshub-4.json.gz \
# && mv genesis.cosmoshub-4.json ~/.gaia/config/genesis.json
# RUN gaiad start --x-crisis-skip-assert-invariants
EXPOSE 26656 26657 1317 9090
USER 0
ENTRYPOINT ["gaiad", "start"]
But I am getting an error when I run docker build ., the error is shown:
=> ERROR [stage-1 3/3] RUN /bin/gaiad init Edima 0.4s
------
> [stage-1 3/3] RUN /bin/gaiad init Edima:
#16 0.432 container_linux.go:380: starting container process caused: exec: "/bin/sh": stat /bin/sh: no such file or directory
------
executor failed running [/bin/sh -c /bin/gaiad init Edima]: exit code: 1
COuld anyone help with how to solve this error?
A "distroless" image usually only contains a very minimal set of libraries and configuration files. It won't contain, for example, a shell, so you can't run shell commands.
The approach I'm used to seeing for a distroless (or similarly scratch) based image is to do all of the necessary setup in previous steps, then COPY content into the final image. Whatever work gaiad init does, if it can reasonably be built into an image, it should be done in a previous stage, and then its result COPYed in.
FROM golang:1.18-alpine AS gaiad-builder
...
RUN CGO_ENABLED=0 make install
# still in the build stage
ENV HOME=/
RUN /go/bin/gaiad init Enima
FROM distroless.dev/static:$IMG_TAG
# (don't RUN anything in the final "FROM distroless" build stage)
COPY --from=gaiad-builder /go/bin/gaiad /gaiad
COPY --from=gaiad-builder /.gaiad/ /.gaiad/
ENV HOME=/
ENTRYPOINT ["/gaiad", "start"]
If that's not an option, then (like ENTRYPOINT and CMD) the RUN directive comes in two forms. If you RUN some command then Docker automatically runs that via a shell; but the distroless image doesn't have a shell, which leads to the /bin/sh: no such file or directory error. You can also pass a JSON array to RUN, which doesn't invoke a shell, but also requires you to manually split up words yourself, and can't do things like environment-variable substitution:
RUN ["gaiad", "init", "Edima"]
If that's not an option, then a distroless image won't work for you. The comments hint at wanting to download more files and run a sequence of commands in the final image. Since you build the application using an Alpine-based image, you can change the final image to match
FROM alpine
COPY --from=gaiad-builder /go/bin/gaiad /bin/
# which includes a POSIX /bin/sh, so this now works again
RUN gaiad init Enima
I’m a fresh beginner on bioinformatics. Recently, I start learning it with the book named “Bioinformatics with Python Cookbook (by Antao, Tiago)”. I met some issues while setting up Docker for Linux. Please see below for the issues:
I was trying to set up the Docker files following the author’s instruction, but I found some files were “failed to download”.
docker build -t bio
https://raw.githubusercontent.com/tiagoantao/bioinf-python/master/docker/2/Dockerfile
Then I still went ahead set up the container following the instruction:
“Now, you are ready to run the container, as follows: docker run -ti -p 9875:9875 -v YOUR_DIRECTORY:/data bio”
I typed as docker run -ti -p 9875:9875 -v C:/Users/guangliang/Desktop/Bioinformation/data bio
However, it gave me an error saying “Unable to find image “bio:latest” locally”.
Can anyone give me any suggestions on this? My thought could be the first step I missed downloading some files for setting the Dockers, but I am not sure if I can fetch these files.
Thank you so much for any comments!
Best regards
Johnny
I tried downloading the docker files a few time, but the error still appears
docker build -t bio
https://raw.githubusercontent.com/tiagoantao/bioinf-python/master/docker/2/Dockerfile
docker run -ti -p 9875:9875 -v C:/Users/guangliang/Desktop/Bioinformation/data bio
In the first issue, I found some files were “failed to download”.
In the 2nd issue, an error saying “Unable to find image “bio:latest” locally”. appears
Here you have a couple of problems:
1) It looks you do not download that docker file and build required docker image locally
2) You are getting that error about not finding image locally because of previous problem
So, you should do like this:
1) Download that Dockerfile (https://raw.githubusercontent.com/tiagoantao/bioinf-python/master/docker/2/Dockerfile). If you cant download that file for some reason, just open it at the git, select all content, copy, than in some folder on your computer make a new file, name it "Dockerfile" and paste the content.
2) Build locally image - go to the folder you download that dockerfile and execute following command:
docker build -t bio .
3)Run your container with docker run ... command
I'm trying to create a docker image. This image should run a shell script "startService.sh" when the container is created. The image was built successfully, but when trying to run the image, I get the following error:
"./startService.sh: 6: ./startService.sh: source: not found"
But I know I copied the startService.sh script into the image. My Dockerfile is shown below.
FROM openjdk:8
VOLUME /opt/att/ajsc/config
COPY startService.sh /startService.sh
RUN chmod 777 /startService.sh
ENTRYPOINT ./startService.sh
Where did I go wrong?
The error isn't saying that your start script isn't found; it's saying that the source command (which your script apparently uses) isn't found. source is a bash-specific synonym for the . command; if you want your script to be compatible with the Docker image's /bin/sh, you need to use . instead.
So at the end of my Dockerfile I have this:
WORKDIR /home
CMD django-admin startproject whattt
CMD /bin/bash
When I create image and then run container, everything works as expected there are no errors, and no errors in the Docker log. However there are still some issues that I cannot seem to figure out.
The first and most important problem is that CMD django-admin startproject is not actually creating any project. AFTER I run the container, then I can manually run django-admin startproject and it works as expected. When I issue this as a CMD from the Dockerfile though, then no project gets created.
The second issue is after the django-admin line, I put a second CMD with /bin/bash so when I run the container it opens a shell (so I can go in and check if my django project was created). Will this create a problem or conflict with the previous django-admin line? If I remove this line, then when I run the container I have no way to open the shell and check if my django project is there do I ?
Any help would be appreciated, thanks.
“There can only be one CMD instruction in a Dockerfile. If you list more than one CMD then only the last CMD will take effect.” via Dockerfile reference. So your first CMD will not take effects.
If you want to execute the bash of your container, try docker exec command, and the document provides example commands so you can follow.
Trying to use docker-compose to build and up a simple Node.js application. Although I ran into the same problem with a Django application so I think I'm just missing some sort of vital step. Here is my Dockerfile:
FROM node:4.2.1
CMD mkdir -p /var/app
COPY . /var/app
EXPOSE 3000
CMD node /var/app/index.js
When I run docker compose up pointed towards a digital ocean machine it throws a node error suggesting it can't find the code in /var/app. Is there some other mechanism I am supposed to use to get my code onto the machine other than docker?
The line CMD mkdir -p /var/app is wrong. It should be only one CMD in a Dockerfile, usually at the end.
Only the last CMD directive in a chain of inherited docker images will be executed.
You should use RUN instead
From Dockerfile reference
There can only be one CMD instruction in a Dockerfile. If you list more than one CMD then only the last CMD will take effect.
The main purpose of a CMD is to provide defaults for an executing container.
Try taking out the mkdir step. You also need to set the working directory.