Install Docker and build a simple node app from dockerfile on Manjaro

September 27, 2018

First you need to install latest docker on Manjaro

sudo pacman -S docker docker-compose docker-machine

Then we need to enable on the startup docker

  1. enable on startup sudo systemctl enable docker
  2. start docker service sudo systemctl start docker
  3. check the docker service status sudo systemctl status docker (must be active)
  4. quit

Once pacman has been completed the installation of Docker on our system we need to do Post-installation steps. now you should be able to use docker with sudo before docker command, but I do not like that, instead I need to create a ‘docker’ group and add my user to this new group and reboot or logout and login to make changes take effect, so.

Check versions of Docker you have:

docker -v
Docker version 18.06.1-ce, build e68fc7a215
docker-machine -v
docker-machine version 0.15.0, build HEAD
docker-compose -v
docker-compose version 1.22.0, build unknown

Use Docker without sudo:

  1. Create docker group sudo groupadd docker
  2. Add your user to docker group sudo usermod -aG docker $USER
  3. logout or reboot to changes take effect

Now, create a Docker Hub account.

In a directory that you preffered, clone git@github.com:carlosgomez2/docker-course.git and cd into docker course directory. At this point we only work for this task in folder ‘dockerfile-assignment-1’, so enter directory and build the docker image

  1. docker build . -t node-6-app to build image
  2. docker container run -p 80:3000 --rm node-6-app
  3. in browser go to localhost:80, you will see the app working

Then we need to push the app image container to Docker Hub, login in console, docker login add your credentials (be aware: if you are pushing from a remote or untrusted machine be sure to docker logout after you are done). Push your app docker push carlosgg/node-6-app:latest

Optional:

We can remove image container locally and pull it from docker hub in this way:

  1. remove local image container docker image rm carlosgg/node-6-app
  2. list your images to ensure to you had removed image docker image ls
  3. now run the image by pulling from Docker Hub docker container run --rm -p 80:3000 carlosgg/node-6-app
  4. you will see in the CLI ‘Unable to find image … locally’ and then ‘Pulling from carlosgg/node-6-app’
  5. open browser and go to localhost:80

Conclusion

Few steps to install docker and enable on Manjaro, download examples repo and use one of them to build a image container and push it to Docker Hub.


Carlos Gomez 2018