How to Build Docker Images with Ansible on Ubuntu 20.04

13 Comments



Building docker images is traditionally completed using a docker file and bash scripts. Today I would like to introduce using configuration management tools to complete this task. Ansible has long been used to build Other types of images and Hosts but has started to get forgotten about in the world of containers. Building an image with Ansible provides numerous benefits compared to the traditional build process.

Docker documentation:
https://docs.docker.com/engine/install/ubuntu/
https://docs.docker.com/engine/install/linux-postinstall/

Github Repo for video:
https://github.com/joeterlecki/docker-images-with-ansible

source

13 Comments
    • blank
      Jonathan MacDonald
      May 26, 2022 22:46 pm Reply

      Thanks, Joe! I walked through the ansible setup and when I tried to run the container, I was getting 'connection reset' in my browser. I looked in the container and noticed that nginx wasn't running. I commented out 'command: tail -f /dev/null' in the playbook and nginx starts as one would expect. I'm a bit green to this so maybe I'm missing something but thought I'd give you and anyone else a heads up what worked for me. Thanks again!

    • blank
      Abel
      May 26, 2022 22:46 pm Reply

      Great video, exactly what I was looking for.. I suscribed, looking forward for more videos

    • blank
      Geo Gmz
      May 26, 2022 22:46 pm Reply

      I'm not sure why your channel does not have more subs.. I watched this video months ago came back to refresh somethings and noticed the subs count.. Your videos are good man makes no sense… But! keep them coming.

    • blank
      Nick M.
      May 26, 2022 22:46 pm Reply

      Technically, you could run ansible in a container so you don't need to install it or it's pyton dependencies. Some development environments are stuck in Py 2 or shouldn't be kept minimalistic. Instead, you can assign an alias to run the ansible utility, adding any other flags as needed. I really like the idea of using Ansible for building containers. I am currently using various shell scripts and they can be quite tricky to write. Ansible seems like an easier path for team members to understand and work with. Thanks for the video.

    • blank
      gregoriodia
      May 26, 2022 22:46 pm Reply

      if logging off and back in is too much a hustle (e.g. lots of ssh parameters, using putty or something), you can always re-login to a new shell instance with:
      su – $USER

    • blank
      gzcwnk
      May 26, 2022 22:46 pm Reply

      dont put background music IMHO.

    • blank
      preetham 7
      May 26, 2022 22:46 pm Reply

      Also never update your images to the latest unless needed. This can cause issues in production. Not a good practice.

    • blank
      preetham 7
      May 26, 2022 22:46 pm Reply

      @ 7:40 you can just do " docker build . -t <image-name> " at your pwd.

    • blank
      Mikhail Radchenko
      May 26, 2022 22:46 pm Reply

      good job, man! thanks

    • blank
      Rock Darko
      May 26, 2022 22:46 pm Reply

      Hi Joe! Really like the smooth and humble vibes of your videos and obviously the content as well. I would definitely be down for a video where you also include ansible-vault into this formula. I work for the health body of my provincial government (I'm Canadian eh) and we are actually using that formula as it promotes building infrastructure as code – it's a solid formula if you ask me. We are for instance deploying kakfa clusters (that includes a zookeeper cluster) that way. Jenkins/Docker/Ansible is a very powerful workflow combination imo. Cheers from Quebec, Canada. I subbed and hopefully I will get to pick your brain at some point.

    • blank
      Matthias Morath
      May 26, 2022 22:46 pm Reply

      A nice option where you also could use your playbook would by to call it in combination with vagrant . Of course without the docker. Commands.

    • blank
      Matthias Morath
      May 26, 2022 22:46 pm Reply

      well you made my day…thanx…

    • blank
      Johnathon Brandis
      May 26, 2022 22:46 pm Reply

      Gday Joe, some great ideas there. I love ansible, and see this as a cool way of building custom images with dependancies. Thanks for donating your time making such awesome videos please keep it up. JB, Sydney AU

Leave us a comment