Create an ISO in Docker that does not have in the hub.docker

0

I am in doubt about the docker, since I already use vmware and virtualbox well, in this case I wanted to install a Firewall the OPNsense and realized that it does not have a container prepared in docker and in this case I wanted to create one but I do not know how docker will run a ISO for a normal installation of what is done on the virtualizers.

    
asked by anonymous 13.09.2016 / 22:36

1 answer

2

As the image does not exist, you will need to create it. This is done with a file called Dockerfile that has more or less this structure:

FROM ubuntu:14.04
EXPOSE 80
VOLUME /src
WORKDIR /src
RUN apt-get update
RUN apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
RUN apt-get install -y nodejs
RUN npm install -g forever
CMD forever -c node app.js

FROM is the name of the base image you are going to use. In this case I use the basic image of Ubuntu. EXPOSE indicates a port that this container will listen to (such as a firewall opening). VOLUME is used to share files between the container and the host machine.

In this case I create in the file structure of my container a / src directory that can be later mounted by the host. It works like the vmware shared folders, virtualbox.

WORKDIR is nothing more than a cd command that indicates that all commands executed by the container must have the / src path as the base. RUN is used to make the container execute a command. In this case I install some packages.

Finally the CMD is a special type of RUN that serves to say what the purpose of the container is, in this case, my container is intended to run a Node application. You can also use ENTRYPOINT for this, however it is most often used to run services.

After setting Dockerfile, you have to go to the directory where it is (using cd) and run the docker build command. This will turn your Dockerfile into an image ready to run with docker run.

Because the image does not exist in the hub, you can send it there. For this you need to create an account in the hub and on your machine to run:

docker login

The command will ask for your login and password for the hub. Finally you use the command below to submit your image to the hub:

docker push seuusuario/suaimagem

So, the next time you need this image, instead of having to create a Dockerfile and build, you can simply do:

docker run seuusuario/suaimagem

Dockerfile reference: link

    
02.11.2016 / 15:35