ScandiPWA (deprecated)
User ManualGitHubSlack
  • ScandiPWA (deprecated)
  • React & PWA for dummies
    • Setting Up Environment and Talking Theory
    • Learning React Hands-on
    • Styling It
    • Learning ScandiPWA Way
  • START & UPGRADE
    • Linux Docker setup
    • Mac Docker setup
    • Setting up the theme with remote M2 server
    • Theme Upgrade to the latest version
    • Automated setup (BETA)
  • A TO Z OVERVIEW
    • Motivation
    • Challenges
    • File structure and UI components
    • Rewriting and Extending A Theme
  • DESCRIPTION OF CONTAINERS
    • Ngrok
  • FAQ
    • Development
    • Installation
    • Billing and license
    • Product support
    • What is PWA?
  • HOW-TO TUTORIALS - INTRODUCTORY
    • Base template
    • Connecting to the GraphQL resolver
    • Extension mechanism
    • Creating GraphQL resolver
    • Debugging and Inspecting
    • Setting Up Frontend
    • File Structure
    • Data Flow
    • Technology Stack
    • Changing environment
    • Theme Build and Configuration
    • Implementing Caching for New Caching Identities
    • Implementing a parent theme
  • HOW-TO TUTORIALS - INTERMEDIATE
    • Debugging in Chrome
    • Configuring XDebug
    • CLI in Docker
    • Postman & GraphQL Playground
    • VSCode Extensions
    • Plugins: implementing
    • Plugins: using and publishing
    • ESlint & StyleLint
    • How To Contribute
    • Migrating to a Newer Version
    • Installation on Existing Magento 2 Sever
    • BEM and Coding Standards
    • Tools of ScandiPWA
    • React Best Practices
  • FAQ
    • Untitled
Powered by GitBook
On this page
  • Pro Tip: use aliases
  • Stack operations
  • App container debug mode
  • Logging
  • Shell access
  • Full rebuild with log attach
  • Rebuild app container without cache
  • Reference
  1. HOW-TO TUTORIALS - INTERMEDIATE

CLI in Docker

PreviousConfiguring XDebugNextPostman & GraphQL Playground

Last updated 4 years ago

Pro Tip: use aliases

# use `dc` to start without `frontend` container
alias dc="docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml"

# use `dcf` to start with `frontend` container
alias dcf="docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml -f docker-compose.frontend.yml"

# use `inapp` to quickly get inside of the app container
alias inapp="docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml -f docker-compose.frontend.yml exec -u user app"

# use `applogs` to quickly see the last 100 lines of app container logs
alias applogs="docker-compose logs -f --tail=100 app"

# use `frontlogs` to quickly see the last 100 lines of frontend container logs
alias frontlogs="docker-compose -f docker-compose.yml -f docker-compose.local.yml -f docker-compose.ssl.yml -f docker-compose.frontend.yml logs -f --tail=100 frontend"

Stack operations

Start and create containers docker-compose up -d

Start - docker-compose start

Restart - docker-compose restart

Stop - docker-compose stop

Stop and remove - docker-compose down

Pull latest containers from repos - docker-compose pull

Check status - docker-compose ps

List open ports - docker-compose ports

App container debug mode

During container build you might need to execute indide it, but due to errors it bootloops.

Here is how to override it:

  • Stop app container docker-compose stop app

  • Execute the app container docker run -it -e COMPOSER_AUTH --entrypoint /bin/bash APP_CONTAINER_NAME

Logging

Logs can be accessed with docker-compose logs -f to fetch all logs from all stack. To watch specific container logs - docker-compose logs -f app can use multiple container names, separated by space

Shell access

To execute into application docker-compose exec -u user app bash -l, it runs default Ubuntu 16.04. Other services in stack are using default ports and open to host, you can use any tools to interact with them directly Service containers run on Alpine local, use docker-compose exec mysql /bin/sh -l

Note the flag -l, passing it you will make “normal” login into shell, with proper expose of updated $PATH and other variables in the system

Full rebuild with log attach

docker-compose -f docker-compose.yml -f docker-compose.local.yml up -d --force-recreate --remove-orphans --build && docker-compose logs -f

Rebuild app container without cache

docker-compose -f docker-compose.yml -f docker-compose.local.yml build --no-cache app

Reference

- docker-compose cli overview and reference

- docker cli overview and reference

https://docs.docker.com/compose/reference/overview/
https://docs.docker.com/engine/reference/commandline/cli/
How to use CLI in Docker