I tried small docker application.
This is my Dockerfile:
FROM openjdk:8-java-alpine
ADD target/hello-world-rest-api.jar hello-world-rest-api.jar
ENTRYPOINT ["java","-c","java -jar /hello-world-rest-api.jar
Getting the below error when I tried to run build cmd.
C:\Docker-SpringBoot-Projects\docker-crash-course-master\01-hello-world-rest-api>docker build -t dowlathbasha/hello-world-rest-api:dockerfile1 .
Sending build context to Docker daemon 16.97MB
Step 1/3 : FROM openjdk:8-java-alpine
manifest for openjdk:8-java-alpine not found
Pls, suggest.
There is no image named, openjdk:8-alpine hosted in Docker Hub
Try using alternative image such as FROM openjdk:8-alpine in Dockerfile
you may use following docker image for java8
FROM adoptopenjdk/openjdk8:x86_64-alpine-jre8u232-b09
RUN mkdir /app
COPY ./target/hello-world-rest-api.jar /app/hello-world-rest-api.jar
WORKDIR /app
CMD ["java", "-jar", "hello-world-rest-api.jar"]
source:- https://hub.docker.com/r/adoptopenjdk/openjdk8
Related
I have simple Dockerfile as below :
FROM centos:centos7
FROM adoptopenjdk/openjdk8:jre8u352-b05-ea-ubuntu-nightly
EXPOSE 8080
WORKDIR /home/centos
COPY ./abc.jar /tmp/abc.jar
CMD ["java" "-jar", "/tmp/abc.jar"]
Now, after building the image , trying to run the container using docker run command , but it is giving error
/bin/sh: 1: [java: not found
I simply don't understand what's the issue here. I'm assuming that , openjdk image will create the java environment and set all PATHS .
Please suggest
Here is my Dockerfile:
FROM golang:1.17.5 as builder
WORKDIR /go/src/github.com/cnosdb/cnosdb
COPY . /go/src/github.com/cnosdb/cnosdb
RUN go env -w GOPROXY=https://goproxy.cn,direct
RUN go env -w GO111MODULE=on
RUN go install ./...
FROM debian:stretch
COPY --from=builder /go/bin/cnosdb /go/bin/cnosdb-cli /usr/bin/
COPY --from=builder /go/src/github.com/cnosdb/cnosdb/etc/cnosdb.sample.toml /etc/cnosdb/cnosdb.conf
EXPOSE 8086
VOLUME /var/lib/cnosdb
COPY docker/entrypoint.sh /entrypoint.sh
COPY docker/init-cnosdb.sh /init-cnosdb.sh
RUN chmod +x /entrypoint.sh /init-cnosdb.sh
ENTRYPOINT ["/entrypoint.sh"]
CMD ["cnosdb"]
Here is my configuration of my jenkins:
But the image docker built didn't have a name.
why?
I haven't used Jenkins for this, as I build from the command line. But are you expecting your name arg to show up in the REPOSITORY and TAG columns? If that is the case, docker has a docker tag command, like so:
~$ docker tag <image-id> repo/name:tag
When I build from the command line, I do it like this:
~$ docker build -t repo/name:0.1 .
Then if I check images:
❯ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
repo/name 0.1 689459c139ef 2 days ago 187MB
Adding to what #rtl9069 mentioned the docker build command can be ran as part of a pipeline. Please take a look at this article https://www.liatrio.com/blog/building-with-docker-using-jenkins-pipelines as it describes it with examples.
I just got started with docker and was following fireship's tutorial, however I encountered a problem when I ran the docker build command. I was expecting a similar output as the video (timestamp). Instead, I got the following:
Dockerfile
FROM node:12
WORKDIR /app #maybe its this? There is no /app directory
COPY package*.json ./
RUN npm install
COPY . .
ENV PORT=8080
EXPOSE 8080
CMD ["npm","start"]
docker build command
docker build -t <my docker id>/firstapp:1.1 .
File tree
D:/
Code/
testing/
Docker/
test1/
Notes
Yes, I have a docker ID.
The docker build command stopped at COPY . ., rather than finishing at CMD ["npm","start"]
CWD (Windows): D:\Code\testing\Docker\test1
I ran the docker build command twice
Questions
Why is this happening?
How can it be fixed?
The reason this occurs is because fireship is running Linux (like Hans Kilian noted) and I am running Windows. To get your image ID, run the docker images command, which will list your images w/ their image ID.
However, I am still not sure why it does not complete all 8 steps.
Here is Dockerfile:
# tag block to refering
FROM node:alpine as builder
WORKDIR /home/server
COPY package.json .
RUN npm install
COPY . .
CMD ["npm", "run", "build"]
# on second step use another core image
FROM nginx
# copy files builded on previous step
COPY --from=builder /home/server/build usr/share/nginx/html
When image is builded on local machine with command 'docker build .' - it works fine, but when I trying to put the project to zeit I get next error:
Step 8/8 : COPY --from=builder /home/server/build usr/share/nginx/html
> COPY failed: stat /var/lib/docker/overlay2/a114ae6aae803ceb3e3cffe48fa1694d84d96a08e8b84c4974de299d5fa35543/merged/home/server/build: no such file or directory
What it can be? Thanks.
Your first stage doesn't actually RUN the build command, so the build directory is empty. Change the CMD line to a RUN line.
One tip: each separate line of the docker build sequence produces its own intermediate layer, and each layer is a runnable Docker image. You'll see output like
Step 6/8: CMD ["npm", "run", "build"]
---> Running in 02071fceb21b
---> f52f38b7823e
That last number is a valid Docker image ID and you can
docker run --rm -it f52f38b7823e sh
to see what's in that image.
I am facing a highly trivial problem wherein the shell script "httpd-service.sh" is not getting executed in the below Dockerfile.
FROM localhost:5000/httpd_custom_image:v6
WORKDIR /opt
ADD httpd-service.sh .
EXPOSE 80
CMD ["/bin/sh","/opt/httpd-service.sh"]
Below is the content of the httpd-service.sh
#!/bin/bash
/usr/local/apache2/bin/httpd
The script httpd-service.sh is getting copied inside /opt in container and has permissions.
Below is the docker version,
[root#vfecare-3 temp]# docker --version
Docker version 17.03.0-ce, build 3a232c8
Can someone let me know what is breaking here?
Got it working in the foreground with the below lines in the Dockerfile.
CMD ["-D", "FOREGROUND"]
ENTRYPOINT ["/usr/sbin/httpd"]