In this document we're going to create a Team Password Manager Docker container. Since the Team Password Manager Docker image does not provide a MySQL database, we'll have to use an existing database. If you don't have a handy MySQL installation, in the next document (How to create a full installation with Docker Compose) we create a full installation including a database.
Assuming you already have Docker installed on your system, follow these steps to create a Team Password Manager container:
- Create a file with the environment variables
- Create and run the container
- Execute the Team Password Manager installer
- Stop/restart/delete the container
1. Create a file with the environment variables
Create a text file to enter the required environment variables in any folder you like, for example env_vars
, open it with your favorite text editor and enter the following:
TPM_SERVER_TIMEZONE=Europe/London TPM_PHP_TIMEZONE=Europe/London TPM_ENCRYPT_DB_CONFIG=0 TPM_CONFIG_HOSTNAME=database_host TPM_CONFIG_PORT=3306 TPM_CONFIG_USERNAME=tpm_username TPM_CONFIG_PASSWORD=tpm_password TPM_CONFIG_DATABASE=tpm_database TPM_UPGRADE=0
Where:
database_host
is the server where your existing database is located. It can be an IP address or, if the database is in your host system and you're using Windows or OSx, it'shost.docker.internal
.tpm_database
is the database that will be used by Team Password Manager. It must be created beforehand.tpm_username
andtpm_password
are the user credentials for a user that has full access totpm_database
.
2. Create and run the container
Open a terminal in your system, go to the folder where you created the env_vars
file and execute this command on the command line:
docker run -d -p 80:80 -p 443:443 --name teampasswordmanager --env-file=env_vars -v tpm_volume:/var/www/html teampasswordmanager/teampasswordmanager:latest
If all goes well you'll be returned a large number (for example, d967b889e...3ce4eca9) and the container will be running. To check if it's running, issue the following command: docker ps
. If you see an output like this one, it means it's running:
Let's dissect this command:
docker run
This Docker command creates and runs a container.-d
means "detached mode", so that the container runs in the background.-p 80:80 -p 443:443
defines the port mappings from the host to the container (host:container). So here, port 80 of the host maps to port 80 of the container, and the same for 443. Note that these two ports (80 and 443) are the ones that the Team Password Manager Docker image exposes. If you wanted to map port 8080 of the host to port 80 of the container, for instance, you should do it like this:-p 8080:80
.--name teampasswordmanager
Sets the name of the container, which you can later use to stop it, delete it, and other actions.--env-file=env_vars
Tells Docker which environment file to use, in this case the one we've created before.-v tpm_volume:/var/www/html
Creates and mounts a volume namedtpm_volume
in the host, targeting the/var/www/html/
folder in the container. This volume is used to persist data. This way, you can destroy the container but since the volume is stored in the host system, it's not destroyed. Specifically, the data persisted is what is stored in the/var/www/html/
folder, which are the three folders described in the image description document:site
,logs
andssl
.teampasswordmanager/teampasswordmanager:latest
The image to create the container from. In this case it's the image that has the latest Team Password Manager version.
3. Execute the Team Password Manager installer
To conclude the installation of Team Password Manager you should execute the Team Password Manager installer. To do this:
• Open your browser and go to http://localhost/index.php/install
. You can replace "localhost" with the IP address of your server or the domain/subdomain that points to it, if you have it configured. Note also that we've used "http" and not "https" in this case. We explain how to configure https in this document: "How to install a https commercial certificate in a Docker container".
• Fill in the data in the Team Password Manager installer screen and click on "Submit data to complete installation".
4. Stop/restart/delete the container
To stop the container execute this command at the command line:
docker stop teampasswordmanager
You can start it again with:
docker start teampasswordmanager
And you can delete the container (once it's stopped) entering this command:
docker rm teampasswordmanager
Note that deleting the container doesn't delete the volume it creates (tpm_volume
in this case). So if you create the container again using the docker run
command as in step 2, you'll be using the same installation.
Document changelog
Nov 18, 2020: | Document created |