Docker
Last updated
Last updated
Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration. To learn more about all the features of Compose, see the list of features.
Currently we can divide the file into 4 pieces frontend, backend, listener
and database.
these project have all different variables.
First, tell Docker what image you want to build the app
service from by specifying that you’ll be building from the projectwerk2/frontend:develop
image.
Here, you’ve mapped port 80 on the host operating system, to port 5000 from the container. That way, when you’ve moved this container to a production host, users of the application can go to the host machine’s port 80 and have those requests answered from the container on port 5000.
Always restart the container if it stops.
Docker lets you store data such as configuration settings, encryption keys, and external resource addresses in environment variables. Docker Cloud makes it easy to define, share, and update the environment variables for your services.
Volumes are the preferred mechanism for persisting data generated by and used by Docker containers. While bind mounts are dependent on the directory structure of the host machine, volumes are completely managed by Docker. Volumes have several advantages over bind mounts:
An environment variable is a dynamic "object" on a computer that stores a value, which in turn can be referenced by one or more software programs in Windows. Environment variables help programs know what directory to install files in, where to store temporary files, where to find user profile settings, and other things. It can be said that environment variables help to create and shape the environment of where a program runs.
you can store your environment variable in a .env file
go the smart-campus-docker-compose
file and open a terminal.
now your docker containers are up and running on your localhost or the ip addr Docker gave you with startup
You can inspect images with docker inspect <tag or id>.
docker-compose
up without the -d
option can also be used to spin up the services. The services will not be run in the background. Output of any of the containers will be shown in the terminal. Ending the terminal will also stop the containers from running.
Stop the application, either by running docker-compose down
from within your project directory in the second terminal, or by hitting CTRL+C in the original terminal where you started the app.