Create an ISO in Docker and you don’t have it in the hub.Docker

Asked

Viewed 276 times

0

I am in doubt about Docker, because I already use Vmware and virtualbox well, in this case I wanted to install a Firewall OPNsense and I realized I don’t have a container prepared in the Docker and in this case I wanted to create one but I don’t know how the Docker will run a ISO for a normal installation of what is done in the virtualizators.

  • Have you thought about using a Puppet image and installing this with Puppet in container creation?

1 answer

2

Since 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 will 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 container and host machine.

In this case I create in the file structure of my container a directory /src that can be mounted later by the host. Works like 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 basis. RUN serves to make the container execute a command. In this case I install some packages.

Finally, CMD is a special type of RUN that serves to say what the purpose of the container is, that is, in this case my container is intended to run a Node application. It is also possible to use ENTRYPOINT for this, but it is more used to run services.

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

Since 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 hub login and password. Finally you use the command below to submit your image to the hub:

docker push seuusuario/suaimagem

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

docker run seuusuario/suaimagem

Reference of the Dockerfile: https://docs.docker.com/engine/reference/builder/

  • Yes it is true but Opnsense it is based on Freebsd and the problem is that its development done in PHP is not yet available a make; make install. Have you heard that to install an OS on docker you use the virtualbox and deletes the kernel startup files and exports to mount. There are two examples being Centos #1 Centos #2 and the Ubuntu.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.