• Worked on Dockerizing a Vue project at work

TIL

Docker has a lot of command line configs to keep track of, but they’re really important. These refer to the docker run command:

  • -p is used to map ports between the Docker container and the host machine. I initially expected the EXPOSE command in the Dockerfile to do this for me, but I learned that mostly just specifies which ports will need mapped. To map port 8080 between my host and the Docker container I needed to add -p 8080:8080 to my docker run command. To map additional ports just add more p flags, eg docker run -p 8080:8080 -p 8081:8081 my_image.

  • --rm automatically removes the container when it stops (eg docker run --rm my_image). Without this you need to manually go in and remove stopped containers, which will sit on your machine indefinitely and take up space.

Docker uses a special internal IP address to refer to the container’s host on OSX, which is 192.168.65.2. I’m currently using that IP instead of localhost in a few JS files that make HTTP requests to an API server running on my host machine. Here is the site I learned this from.