I just want to make sure I have understood Docker correctly.
Basically, Docker is a development environment that can be shared between developers without the need of installing any additional software on the local machines. With DockerHub you can share the development image or you can push the Dockerfile (and other php. mysql. dockerfiles needed) to the project repository in GitHub, GitLab etc. and use it like that.
Am I correct?
I know it is much more than that, but I just want to be sure if my basic grasping of Docker is on the right track.
Thank you for reading and taking your time to answer.
@Tray2 Yeah, I have had my share of deploying dev environments to public servers. Fortunately it was not such a big deal since I managed to fix things quickly. Core memory unlocked :)
@mega_aleksandar Docker is basically a description of an environment. That environment is then contained in a, well, container.
So you can declare that your project needs PHP 8.2.13, and Docker will use an image for that specific version of PHP for your project. This means you don’t have to install PHP on your own computer; that you can run multiple versions of PHP for different projects; but any projects that do share an exact version will re-use the same image (but not container).
Theoretically, once you have a Dockerfile accurately describing your project’s environment, you can run the project on any machine (as it’ll pull down the same versions of things, and configure them in exactly the same way).
@martinbean Great. That should be true for everything else, right? Like Node version, mysql version etc. Aka. I make a dockerfile - description of environment - (and all other accompanying php/mysql/nginx/whatever dockerfiles for building and running the containers), share that with my colleagues and we will all be "synced" in terms of development environment. That dev environment can basically replicate the future production environment?
@Mega_Aleksandar Yeah. You’ll end up needing to use Docker Compose for adding things like a MySQL database, Node, etc to your environment.
Docker Compose is basically just a YAML file that describes the “services” in your stack: so your PHP application would be a service, your MySQL database would be a service, the nginx instance would be a service, etc. If you include this docker-compose.yml file in your project, then theoretically someone can clone your project, and run docker compose up to build the environment and get it running on their machine.
By sharing the Dockerfile or development image, developers can quickly set up the same development environment on their local machines, reducing the configuration discrepancies and potential conflicts that can arise when working with different setups.
@JaylonFranecki Yeah, now I understand that, basically whatever machine the developer has, if I send the dockerfile and the yaml files for the compose up command, the developer will have the same environment as I do, right?