# Introduction to Docker
###### tags: `tutorial` `electrical_system` `NTURT` `software`
##### Author: @QuantumSpawner
## Why using docker
Check out the official website of docker: [docker](https://www.docker.com/).
Long story short, by using docker, you can avoid unnecessary environment setups as a result of different computers with different software installed, and this is the main reason why we opt to develop our programs in docker containers.
## Installing docker on ubuntu
Installation guide: [Install Docker Engine on Ubuntu](https://docs.docker.com/engine/install/ubuntu/)
Configure docker to run on with non-root users, this is mandatory as maging docker as root user may cause potential problems. Please checkout `Manage Docker as a non-root user` chapter in [Post-installation steps for Linux](https://docs.docker.com/engine/install/linux-postinstall/).
## Using our docker environment
Please checkout: [NTURacingTeam/docker](https://github.com/NTURacingTeam/docker) and follow the instructions in the `README.md` file.
:::info
If you barely understand what the documentation is talking about or don't know what image to build and how to use it, please follow the short hands below.
For building the image
```bash=
# in the directory where you cloned the repository
./build_image ros2_host
```
Then create a container by
```bash=
./start_container create ros2 ros2_host
```
After the above initialization stepts, you can use the shell of the container everytime afterwards by
```bash=
./start_container shell ros2
```
and exit the container's bash by
```bash=
exit
```
:::
:::warning
If you want to clone repositories, please do so outside the container (on the host machine) in the directory `WHERE_YOU_CLONED_THE_DOCKER_REPOSITORY/package/YOUR_CONTAINER_NAME`, the directory which links to `~/ws/src` in docker container for development convenience.
If you followed the short hand above, `YOUR_CONTAINER_NAME` is `ros2`.
:::
Please utilize the provided docker environment when you see
:::success
Please utilize the provided docker environment.
:::
in the `homework`/`topic` sections of other tutorials (which is mainly for software group courses).
:::warning
All of our softwares are developed using such environment, and we will grade your homeworks/topics the same. Hence, please also utilize it as your developing environment, or we are **NOT RESPONSIBLE** for environment issues when trying to run your homeworks/topics.
:::
## Advenced topics
:::info
The following are optional materials and you can feel free to skip them.
:::
### Using docker
You can create your docker containers and run it using `docker run`, please checkout: [docker run reference](https://docs.docker.com/engine/reference/commandline/run/).
You can also run multiple containers by using `docker-compose` with `docker-compose.yaml` file, please checkout: [docker-compose reference](https://docs.docker.com/compose/)
### Creating your own docker image
Though in NTURacingTeam we will provide you with our own version of docker image, but you can also create your own version using custom `Dockerfile`, please checkout: [Dockerfile reference](https://docs.docker.com/engine/reference/builder/).
And you can build it using `docker build`, please checkout: [docker build reference](https://docs.docker.com/engine/reference/commandline/build/).
### More advanced topics
Hopefully the following topics will give you motivation and insight to diver deeper into docker.
- Make your own cloud server: [How To Install Nextcloud On Your Server With Docker](https://blog.ssdnodes.com/blog/installing-nextcloud-docker/)
- Make your own git server: [Set Up a Git HTTP Server on Docker](https://linuxhint.com/setup_git_http_server_docker/)
:::info
Note: This is only a motivation, not a topic homework you have to finish.
:::