1

I have dockerfile for nodejs and mongodb installation.I installed docker plug-in and created a job in that. Now i need to build the image from the Dockerfile. I have to apply copy command in Dockerfile, to copy the nodejs app into container.

FROM ubuntu:latest

#OS Update
RUN apt-get update
RUN apt-get -y install git git-core unzip python-pip make wget build-essential python-dev libpcre3 libpcre3-dev libssl-dev vim nano net-tools iputils-ping supervisor curl supervisor

WORKDIR /home/wipro
#Mongo Setup
RUN curl -O http://downloads.mongodb.org/linux/mongodb-linux-x86_64-3.0.2.tgz && tar -xzvf mongodb-linux-x86_64-3.0.2.tgz && cd mongodb-linux-x86_64-3.0.2/bin && cp * /usr/bin/
#RUN mongod --dbpath /home/azureuser/CI_service/data/ --logpath /home/azureuser/CI_service/log.txt --logappend --noprealloc --smallfiles --port 27017 --fork

#Node Setup
#RUN curl -O https://nodejs.org/dist/v0.12.7/node-v0.12.7.tar.gz && tar -xzvf node-v0.12.7.tar.gz && cd node-v0.12.7
#RUN cd /opt/node-v0.12.7 && ./configure && make && make install
#RUN cp /usr/local/bin/node /usr/bin/ && cp /usr/local/bin/npm /usr/bin/
RUN wget https://nodejs.org/dist/v0.12.7/node-v0.12.7-linux-x64.tar.gz
RUN cd /usr/local && sudo tar --strip-components 1 -xzf /home/wipro/node-v0.12.7-linux-x64.tar.gz
RUN npm install forever -g

#CI SERVICE
ADD prod /home/wipro/
ADD servicestart.sh /home/wipro/
RUN chmod +x /home/wipro/servicestart.sh
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
CMD ["sh", "/home/wipro/servicestart.sh"]

EXPOSE 80
EXPOSE 27017

Here in dockerfile, I'm trying to Add prod and servicestart.sh into image.In linux its possible. I'm new to windows. How to add those files into image from Windows.?

While building the job, facing issue in docker plug-in

FATAL: uri was not specified java.lang.NullPointerException: uri was not specified
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:204)    
at com.github.dockerjava.core.DockerClientConfig$DockerClientConfigBuilder.withUri(DockerClientConfig.java:406)     
at org.jenkinsci.plugins.dockerbuildstep.DockerBuilder$DescriptorImpl.createDockerClient(DockerBuilder.java:120)    
at org.jenkinsci.plugins.dockerbuildstep.DockerBuilder$DescriptorImpl.getDockerClient(DockerBuilder.java:204)   
at org.jenkinsci.plugins.dockerbuildstep.DockerBuilder.perform(DockerBuilder.java:68)   
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)    
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:814)    at hudson.model.Build$BuildExecution.build(Build.java:199)  
at hudson.model.Build$BuildExecution.doRun(Build.java:160)  
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:593)    
at hudson.model.Run.execute(Run.java:1567)  
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)  
at hudson.model.ResourceController.execute(ResourceController.java:88)  
at hudson.model.Executor.run(Executor.java:237)

What URI need to specify ?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
user2439278
  • 1,222
  • 7
  • 41
  • 75

1 Answers1

1

You need to make sure those files are:

  • in the same folder as the Dockerfile, in order to be part of the docker build context,
  • in a folder starting with c:\Users\<yourLogin>, since only that folder is mounted in the VM boot2docker TiynyCore-based Linux host.

The OP confirms in the comments using the Docker build step plugin for Jenkins, with the URI

docker daemon -D -H tcp://127.0.0.1:2376
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Do we need to install docker in windows. While building, Im getting error as docker server URL not specified in Jenkins – user2439278 Feb 09 '16 at 06:19
  • Error message : FATAL: uri was not specified – user2439278 Feb 09 '16 at 06:48
  • @user2439278 if your slave execute docker commands on Windows, docker-machine needs to be installed (just one exe to copy from https://github.com/docker/machine/releases), and the command returned by `docker-machine env` need to be executed for any docker command to work. – VonC Feb 09 '16 at 06:55
  • docker toolkit and docker machine installed in my Windows.How to proceed now? – user2439278 Feb 09 '16 at 07:01
  • @user2439278 forget tookit, just docker-machine.exe is enough: `docker-machine create` and then execute the result of `docker-machine env` – VonC Feb 09 '16 at 07:04
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/102961/discussion-between-user2439278-and-vonc). – user2439278 Feb 09 '16 at 07:06
  • docker-machine.exe downloaded as mentioned in above link. Now when i tried to create docker-machine create , it asks for drive name? what i need to specify? – user2439278 Feb 09 '16 at 07:08
  • @user `docker-machine create -d virtualbox default` (assuming virtualbox is installed) – VonC Feb 09 '16 at 07:09
  • Error message : "This computer does'nt have VT-X/AMD-v enabled.Enabling it in the BIOS is mandatory". I'm using azure windows server – user2439278 Feb 09 '16 at 07:12
  • @user2439278 I thought you were on a regular windows box. For Azure: https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-docker-machine/, using the azure driver: https://docs.docker.com/machine/drivers/azure/ – VonC Feb 09 '16 at 07:16
  • instead of Windows,if i use ubuntu server ,do we neeed virtualbox to run the docker-machine create – user2439278 Feb 09 '16 at 07:18
  • @user2439278 no docker-machine required there: just `curl -sSL https://get.docker.com/ | sh` or more recent installation process like https://docs.docker.com/engine/installation/linux/ubuntulinux/ – VonC Feb 09 '16 at 07:23
  • So , in ubuntu azure sever, just docker need to be installed right? – user2439278 Feb 09 '16 at 07:28
  • @user2439278 correct, since docker runs natively on (recent) Linux kernel. No need for VM there. – VonC Feb 09 '16 at 07:33
  • So then what URI i need to specify in Jenkins (For docker) – user2439278 Feb 09 '16 at 07:35
  • @user2439278 are you using the docker jenkins plugin (this one: https://wiki.jenkins-ci.org/display/JENKINS/Docker+build+step+plugin) ? Or this one? https://wiki.jenkins-ci.org/display/JENKINS/Docker+Plugin – VonC Feb 09 '16 at 07:36
  • I installed both the plugins in jenkins – user2439278 Feb 09 '16 at 07:38
  • @user2439278 What URI did you end up using? – VonC Feb 09 '16 at 15:42
  • started docker service : docker daemon -D -H tcp://127.0.0.1:2376 – user2439278 Feb 10 '16 at 04:54
  • @user2439278 Great! Which of the two Docker Jenkins plugin did you use? – VonC Feb 10 '16 at 05:02
  • Docker build step plugin – user2439278 Feb 10 '16 at 05:04
  • i can able to create image from dockerfile. But unable to start the container. Created a new Question for this : http://stackoverflow.com/questions/35293195/unable-to-start-container-from-jenkins kindly help to fix – user2439278 Feb 10 '16 at 05:05