diff --git a/README.md b/README.md index ed61c07..f4843ce 100644 --- a/README.md +++ b/README.md @@ -967,10 +967,6 @@ ALLOWED_HOSTS.extend( # -d flag allows to run the containers in the background, so that we can see the output of the containers $ docker-compose -f docker-compose-deploy.yml up -d ``` -- Rebuild and run services (if you've made any changes to the project) -```bash -$ docker-compose -f docker-compose-deploy.yml up -d --build -``` - Open the browser and go to the **Public IPv4 DNS** address of the EC2 instance [Back to top ↑](#recipe-api) diff --git a/commands.md b/commands.md index 659820c..5d48457 100644 --- a/commands.md +++ b/commands.md @@ -1,4 +1,40 @@ # Useful Commands +## EC2 Instance +- Connect to the EC2 instance +```bash +$ ssh ec2-user@ +``` +- Build the docker image based on specific docker compose file +```bash +$ docker-compose -f docker-compose-deploy.yml build +``` +- Run the docker containers based on specific docker compose file +```bash +$ docker-compose -f docker-compose-deploy.yml up +``` +- Rebuild and run the docker containers based on specific docker compose file +```bash +$ docker-compose -f docker-compose-deploy.yml up --build +``` +- Rebuid the specific service based on the specific docker compose file if you made changes to project files and pulled them from GitHub +```bash +$ docker-compose -f docker-compose-deploy.yml build +``` +- Restart the specific service based on the specific docker compose file after you rebuid it +```bash +$ docker-compose -f docker-compose-deploy.yml up --no-deps -d +# --no-deps - don't restart dependent services (ngix, postgres) since we only want to restart the service we rebuid +``` +- Remove volumes of specific docker-compose.yml file +```bash +$ docker-compose -f docker-compose-deploy.yml down --volumes +``` +- Check logs of the container on production +```bash +$ docker-compose -f docker-compose-deploy.yml logs +``` + +## Docker - Start Docker Daemon ```bash $ sudo service docker start @@ -11,11 +47,7 @@ $ docker build . ```bash $ docker compose build ``` -- Build the docker image based on specific docker compose file -```bash -$ docker compose -f docker-compose-deploy.yml build -``` -- Rebuild the docker image +- Rebuild the docker images ```bash $ docker compose up --build ``` @@ -23,14 +55,6 @@ $ docker compose up --build ```bash $ docker compose up ``` -- Run the docker containers based on specific docker compose file -```bash -$ docker compose -f docker-compose-deploy.yml up -``` -- Rebuild and run the docker containers based on specific docker compose file -```bash -$ docker compose -f docker-compose-deploy.yml up --build -``` - Check images ```bash $ docker images @@ -59,14 +83,6 @@ $ docker volume ls ```bash $ docker volume rm ``` -- Remove volumes of specific docker-compose.yml file -```bash -$ docker-compose -f docker-compose-deploy.yml down --volumes -``` -- Check logs of the container on production -```bash -$ docker-compose -f docker-compose-deploy.yml logs -``` ## Run commands inside the container - Using `docker compose run` command