title: Specifying ports both for the docker and compose file
body: <p>I've built a Docker compose file to run database and a nodejs microservice in their own containers.</p>
  
  <p>The database seems to stops working if I don't specify the EXPOSE ports, even though I've specified them in the compose file. Do we have to specify ports in both places?</p>
  
  <p><strong>database/Dockerfile</strong></p>
  
  <pre><code>FROM mysql
  
  ENV MYSQL_DATABASE=test
  ENV MYSQL_ROOT_PASSWORD=password
  
  EXPOSE 6603:3306
  
  COPY ./schema.sql /docker-entrypoint-initdb.d/
  </code></pre>
  
  <p><strong>docker-compose.yml</strong></p>
  
  <pre><code>version: '3'
  
  services:
    database:
      build:
        ./database
      ports:
        - "6603:3306"
      image: "test-mysql"
      container_name: "test-mysql"
  
    web:
      build:
        ./service
      ports:
        - "8080:8080"
      depends_on:
        - database
      image: "test-nodejs"
      container_name: "test-nodejs"
      restart: on-failure
  </code></pre>
  
  <p>Do I've to specify ports <code>6603:3306</code> in both <strong>Database/Dockerfile</strong> and <strong>docker-compose.yml</strong> file?</p>