Does Digital Ocean have a Docker image (or a Dockerfile to create one) that is exactly the same as the one in the Ubuntu 18.04 droplet?

January 8, 2019 1.8k views
Docker Ubuntu 18.04

Hi,
I would like to “emulate” a Digital Ocean Ubuntu droplet in my Mac (iOS) locally. Does Digital Ocean have an image (or a Dockerfile to create one) that is exactly the same as the one in the droplet? That’s my question, if you need more details about it, there you have:

  • Why I’m asking it? I would like to emulate on my Mac what is going on in the server (droplet). For ex, I would like to make mySQL to restart if the server reboots. I can’t reboot the droplet, so I want to test if my code works on my local version. (Actually, can I reboot the droplet to test if mySQL restarts?)
  • What have I tried so far? I tried to create an Ubuntu image via Dockerfile (“FROM Ubuntu”), but when I install mysql-server on this image via Dockerfile (“sudo apt install -y mysql-server”) and I open the bash of this image (“exec”), mysql can’t be started (“fail” and “ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ’/var/run/mysqld/mysqld.sock’ (2)”). If I go inside the bash of the container, uninstall mysql and install manually, then I can run it. But to emulate what I want, I need that the image has mysql running automatically.

I know that Amazon has something similar (https://aws.amazon.com/amazon-linux-ami/), so I guess that maybe DO have its own too.
Thank you.

4 Answers

Hey friend,

Great question! We don’t have one, but our images are basically just this: https://cloud-images.ubuntu.com/

That said, I’d like to focus more on the reasons for doing it, as I think there may be a better path.

Making MySQL start on boot should be just something like this:

systemctl enable mysql

That enables the service to start on boot. No need to test it, as it will work unless another circumstance exists that needs your manual intervention, such as a corrupted database. There’s really no good way to automate that specific scenario that doesn’t put you at greater risk.

Jarland

Hello Jarland,
Thank you for your answer!
Just a follow up, please: is it possible to boot the droplet from the console, to test this mySQL at boot, anyway?
Thanks.

  • Absolutely, you can reboot the droplet any time. A simple “reboot” command from console or SSH should do fine, though we also offer a Power Cycle button in our cloud panel. Just remember that reboot is a thing often misunderstood. A reboot is a chance to see recent changes go into action, and while that should be perfectly fine this is a time where I hear this phrase most often:

    It was working before.

    Applying changes made to the system since last boot means putting them to the test. If changes were made that broke the system, you might not know until reboot. Changes can be automatic in some cases, or they can be manual changes that were made poorly.

    There should never be anything to fear from a reboot, but that doesn’t stop people from breaking their systems and then wondering what happened. Always have backups, always be aware of what it is that you’ve changed on the system should a need to revert it arise.

Thank you, you helped a lot!

Thank you, you helped a lot!

Have another answer? Share your knowledge.