Hosting stuff on docker

first i decided to load docker on my system since i am using ubuntu it was pretty simple
i used this website by docker guys as reference: https://docs.docker.com/install/linux/docker-ce/ubuntu/ .

You need to setup their own repository and key for that repository.

after that you need to install all requirements including docker engine.

sudo apt-get install docker-ce docker-ce-cli containerd.io

now you should test it.

sudo docker run hello-world

now you just need to install containers and set them up for that you can use official docker hub or one of unofficial registries docker hub.

It’s worth mentioning that this is a fantastic use for snap on Ubuntu. The snap version of docker has been great where I’ve used it so it could be a good solution for you as https://snapcraft.io/docker

an example of setting up an container to work
For this example i will be using mysql container

mysql docker hub

first you need to pull docker image from the hub

sudo docker pull mysql

where you can also add a version using tags like in the example bellow

sudo docker pull mysql:5.7

sudo docker run -p 0.0.0.0:3306:3306 -restart=always --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -it mysql:8.0

Lets brake it down

  • docker run is a command that creates a container from image and does first start
  • -p 0.0.0.0:3306:3306 is an argument that binds the computer port 3306 on any ip(0.0.0.0 tells it any ip) to in container port 3306
  • –restart=always will tell it to restart the conatiner on reboot or error
  • –name argument defines name for the container it is advised to give your container a name otherwise you will be getting an random name if you do not define the name you will still be able to control it with its randomised ID that gets assigned during creation
  • -e argument passes the MYSQL_ROOT_PASSWORD=my-secret-pw to container as a environment variable
  • -it will tell docker to on first start put you into the container where if need be you can get data from first log
  • mysql:5.7 tells it what specific image and tag to use

your mysql container is setup

1 Like

seen that but couldnt define -v outside of home folder so i do not like to use it