Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Mega_Aleksandar's avatar

Docker as development environment

Hello everyone,

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.

Best reguards,

Mega Aleksandar

0 likes
8 replies
Tray2's avatar

Docker can be used for Development, and in can also be used in production. Just make sure that you don't use a development setup in production.

1 like
Mega_Aleksandar's avatar

@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 :)

Thank you for your response, much appreciated.

martinbean's avatar

@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).

1 like
Mega_Aleksandar's avatar

@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?

Thank you for the response, much appreciated.

martinbean's avatar

@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.

1 like
Mega_Aleksandar's avatar

@martinbean Yeah, I mean, Docker for desktop (at least for Windows) is the go-to thing for that. Thank you so much for taking your time to respond.

1 like
JaylonFranecki's avatar

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.

1 like
Mega_Aleksandar's avatar

@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?

Thank you again for taking your time to respond.

Please or to participate in this conversation.