I'm trying to do a auto build on hub.docker.com using a ADD with files from a URL. I have the following docker file on github, builds are being triggered:
FROM ubuntu:14.04
MAINTAINER Andy Cobley "andy#example.org"
ENV REFRESHED_AT 2015-29-04
RUN apt-get update
RUN apt-get install -y nginx
RUN mkdir -p /var/www/html
ADD http://example.org:8080/global.conf /etc/nginx/conf.d/
ADD http://example.org:8080/nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
ENTRYPOINT ["/usr/sbin/nginx"]
The files are not being added into the container. I can confirm the files do exist on the server and are accessible. Is there something I'm missing ?
As your first ADD ends with a /, docker thinks the source (global.conf) is a directory, try with ADD http://example.org:8080/global.conf /etc/nginx/conf.d/global.conf
I think I've solved this. building remotely in this situation you need to do a docker pull before doing a docker run.
Related
I am new to docker, and it is my first time meeting such error.
This is my DockerFile
FROM rust:latest as builder
ENV APP mapservice
WORKDIR /usr/src/$APP
COPY . .
RUN cargo install --path .
FROM debian:buster-slim
RUN apt-get update && rm -rf /var/lib/apt/lists/*
COPY --from=builder /usr/local/cargo/bin/$APP /usr/local/bin/$APP
#export this actix web service to port 8080 and 0.0.0.0
EXPOSE 8080
CMD ["mapservice"]
And when I run
docker run -it --rm -p 8080:8080 mapservice
I got an error like:
mapservice: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory
I have no idea why would I got this error. Perhaps I have my APIKEY hardcoded in the main.rs??Does anyone know how to fix this problem? My laptop is M1pro Mac.
I try to run another sample project with a similar dockerfile, and everything is fine with it. I also tried to deploy it on AWS, which gives me another health check error on 8080. Is it something wrong with my docker file?
I am trying to make my application work in a Linux container. It will eventually be deployed to Azure Container Instances. I have absolutely no experience with containers what so ever and I am getting lost in the documentation and examples.
I believe the first thing I need to do is create a Docker image for my project. I have installed Docker Desktop.
My project has this structure:
MyProject
MyProject.Core
MyProject.Api
MyProject.sln
Dockerfile
The contents of my Dockerfile is as follows.
#Use Ubuntu Linux as base
FROM ubuntu:22.10
#Install dotnet6
RUN apt-get update && apt-get install -y dotnet6
#Install LibreOffice
RUN apt-get -y install default-jre-headless libreoffice
#Copy the source code
WORKDIR /MyProject
COPY . ./
#Compile the application
RUN dotnet publish -c Release -o /compiled
#ENV PORT 80
#Expose port 80
EXPOSE 80
ENTRYPOINT ["dotnet", "/compiled/MyProject.Api.dll"]
#ToDo: Split build and deployment
Now when I try to build the image using command prompt I am using the following command
docker build - < Dockerfile
This all processed okay up until the dotnet publish command where it errors saying
Specify a project or solution file
Now I have verified that this command works fine when run outside of the docker file. I suspect something is wrong with the copy? Again I have tried variations of paths for the WORKDIR, but I just can't figure out what is wrong.
Any advice is greatly appreciated.
Thank you SiHa in the comments for providing a solution.
I made the following change to my docker file.
WORKDIR app
Then I use the following command to build.
docker build -t ImageName -f FileName .
The image now creates successfully. I am able to run this in a container.
Everytime I build the container I have to wait for apk add docker to finish which takes a long time.
Since everytime it downloads the same thing, can I somehow force Docker to cache apk's downloads for development purposes?
Here's my Dockerfile:
FROM golang:1.13.5-alpine
WORKDIR /go/src/app
COPY src .
RUN go get -d -v ./...
RUN go install -v ./...
RUN apk add --update docker
CMD ["app"]
BTW, I am using this part volumes: - /var/run/docker.sock:/var/run/docker.sock in my docker-compose.yml to use sibling containers, if that matters.
EDIT: I've found google to copy docker.tgz in Chromium:
# add docker client -- do not install docker via apk -- it will try to install
# docker engine which takes a lot of space as well (we don't need it, we need
# only the small client to communicate with the host's docker server)
ADD build/docker/docker.tgz /
What is that docker.tgz? How can I get it?
Reorder your Dockerfile and it should work.
FROM golang:1.13.5-alpine
RUN apk add --update docker
WORKDIR /go/src/app
COPY src .
RUN go get -d -v ./...
RUN go install -v ./...
CMD ["app"]
As you are copying before installation, so whenever you change something in src the cache will invalidate for docker installtion.
Whenever you have a COPY command, if any of the files involve change, it causes every command after that to get re-run. If you move your RUN apk add ... command to the start of the file before it COPYs anything, it will get cached across runs.
A fairly generic recipe for most Dockerfiles to accommodate this pattern looks like:
FROM some-base-image
# Install OS-level dependencies
RUN apk add or apt-get install ...
WORKDIR /app
# Install language-level dependencies
COPY requirements.txt requirements.lock ./
RUN something install -r requirements.txt
# Install the rest of the application
COPY main.app ./
COPY src src/
# Set up standard run-time metadata
EXPOSE 12345
CMD ["/app/main.app"]
(Go and Java applications need the additional step of compiling the application, which often lends itself to a multi-stage build, but this same pattern can be repeated in both stages.)
You can download Docker x86_64 binaries for mac, linux, windows and unzip/untar and make it executable.
Whenever you are installing any packages in Docker container those should go at the beginning of Dockerfile, so it won’t ask you again to install same packages and COPY command part must be at the end of Dockerfile.
I'm so confuse that Openshift offer a way to set up document workstation locally with ascii_binder, that's ok, i can do it. but there is question, i want to set up openshift-docs in docker container, any way i have tried is useless.
Here is my idea:
I use asciibinder build in openshift-docs and generated _preview directory
After that, I made a image base on nginx and copy all files include _preview directory in to image's directory /usr/share/nginx/html.
After image generated, i use docker run to setup a container.
I entered in the container, changed the default.conf in /etc/nginx/conf.d, made the root become /usr/share/nginx/html/_preview/openshift-origin/latest.
After that, i restart container and entered it again.
Changed current directory to /usr/share/nginx/html , and use command asciibinder watch.
But when i view it in browser, there are many sources like js and css not found.
is my idea right? if it's wrong, so How can i set up openshift-docs in docker container?
my Dockerfile
FROM nginx:1.13.0
MAINTAINER heshengbang "trulyheshengbang#gmail.com"
ENV REFRESHED_AT 2018-04-06
RUN apt-get -qq update
RUN apt-get -qq install vim
RUN apt-get -qq install ruby ruby-dev build-essential nodejs git
RUN gem install ascii_binder
COPY . /usr/share/nginx/html/
CMD ["nginx", "-g", "daemon off;"]
Use this:
https://github.com/openshift-s2i/s2i-asciibinder
They even supply an example of deploying:
https://github.com/openshift/openshift-docs.git
The README only shows s2i command line usage to build a docker image and run it, but to deploy in OpenShift you can run:
oc new-app openshift/asciibinder-018-centos7~https://github.com/openshift/openshift-docs.git
oc expose svc openshift-docs
You can deploy an asciibinder website on OpenShift with the following template: https://github.com/openshift/openshift-docs/blob/master/asciibinder-template.yml.
You can import this with
oc create -f https://raw.githubusercontent.com/openshift/openshift-docs/master/asciibinder-template.yml
Then deploy from the web console via
Make sure you have an assemble script similar to https://github.com/openshift/openshift-docs/blob/master/.s2i/bin/assemble in your project.
I have branched both the node red git repo and the node red docker image and am trying to modify the settings.js file to enable Projects Functionality. The settings file that ends up in the Docker Container does not seem to be my modified one. My aim is to use the Docker image in a Cloud Foundry environment.
https://github.com/andrewcgaitskellhs2/node-red-docker.git
https://github.com/andrewcgaitskellhs2/node-red.git
I am also trying to install git and ssh-keygen at the time of the Docker build to allow Projects to function. I have added these in the Package.json files for both the node red app and image git repos.
If I need to start from scratch, please let me know what steps I need take.
I would welcome guidance on this.
Thank you.
You should not be trying to install ssh-keygen and git via the package.json file.
You need to use the Node-RED Dockerfile as the base to build a new Docker container, in the Dockerfile you should use apt-get to install them and to include an edited version of the settings.js Something like this:
FROM nodered/node-red-docker
RUN apt-get install git ssh-client
COPY settings.js /data
ENV FLOWS=flows.json
ENV NODE_PATH=/usr/src/node-red/node_modules:/data/node_modules
CMD ["npm", "start", "--", "--userDir", "/data"]
Where settings.js is your edited version that is in the same directory as the Dockerfile
Edited following #knolleary's comment:
FROM nodered/node-red-docker
COPY settings.js /data
ENV FLOWS=flows.json
ENV NODE_PATH=/usr/src/node-red/node_modules:/data/node_modules
CMD ["npm", "start", "--", "--userDir", "/data"]
It is not necessary to change the image. For persistence, you will mount a host directory into the container at /data, e.g. like this:
docker run --rm -d -v /my/node/red/data:/data -p 1880:1880 nodered/node-red
A settings.js file will get created in your data directory, here /my/node/red/data. Edit this file to enable projects, then restart the container.
It is also possible to place a settings.js file with projects enabled into the directory that you mount to /data inside the container before the first start.