ByteInternet / hypernode-docker

Fast and easy Docker for Magento development
https://community.hypernode.io/hypernode-docker
35 stars 8 forks source link

OSX Needs some more thoughts, following the README.md is not sufficient #3

Open mikebranderhorst opened 6 years ago

mikebranderhorst commented 6 years ago

"Get the IP address" and "Log in to the container" described in the README don't work (on OSX).

# Find the container ID
docker ps

# Find the IP address of the container
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <the container ID>

# or old syntax
docker inspect -f '{{ .NetworkSettings.IPAddress }}' <the container ID>

# or simple alternative
docker inspect <the container ID> | grep "IPAddress"

But then it is impossible to connect to a docker container ip (on OSX). https://docs.docker.com/docker-for-mac/networking/#known-limitations-use-cases-and-workarounds

The latest Docker for Mac supports better filesystem support (docker-sync is not needed anymore, or is it still faster ?).

Maybe provide a docker-compose.yml for OSX ? This one will be a good start I think:

https://gist.github.com/mikebranderhorst/8c6dd808a2c44aed5cbce2d74181e4f6

# docker-compose.yml (this file)
#
# create    $ docker-compose up --build --detach --quiet-pull
# stop      $ docker-compose stop
# start     $ docker-compose start
# delete    $ docker-compose down
# logs      $ docker-compose logs --follow
# processes $ docker-compose top
# bash to / $ docker-compose exec --user app hypernode bash
# bash to ~ $ docker-compose exec --user app hypernode bash -c 'cd $BUILDENV; exec "${SHELL:-bash}"'
# db passwd $ docker-compose exec --user app hypernode bash -c 'cd $BUILDENV; cat .my.cnf | grep password'
#
#   /\  /\_   _ _ __   ___ _ __ _ __   ___   __| | ___
#  / /_/ / | | | '_ \ / _ \ '__| '_ \ / _ \ / _` |/ _ \
# / __  /| |_| | |_) |  __/ |  | | | | (_) | (_| |  __/
# \/ /_/  \__, | .__/ \___|_|  |_| |_|\___/ \__,_|\___|
#         |___/|_|
#
# https://community.hypernode.io/hypernode-docker/
# https://github.com/ByteInternet/hypernode-docker
#
# http://localhost:8880
# $ ssh app@127.0.0.1 -p 2222
# > ssh password: insecure_docker_ssh_password
# $ mysql -h 127.0.0.1 -P 3307 -u app -p'<passwd>'
# > db password: replace <passwd> with password from exec

version: "3.6"

services:

  hypernode:

    container_name: hypernode-docker

    image: docker.hypernode.com/byteinternet/hypernode-docker:latest

    ports:
      - "2222:22" # for ssh or use docker-compose exec instead
      - "8880:80"   # ~/public
      - "8443:443"  # ~/public
      #- "8880:8880" # ~/staging
      #- "8443:8443" # ~/staging
      - "3307:3306" # for mysql or use ssh tunnel instead (2222)

    # $ mkdir -p ./data-web/magento2
    # $ mkdir -p ./data-web/public
    # $ echo "<?php echo 'public';" > ./data-web/public/index.php
    # $ mkdir -p ./data-web/staging
    # $ echo "<?php echo 'staging';" > ./data-web/staging/index.php

    volumes:
      - ./data-web/magento2:/data/web/magento2/
      - ./data-web/public:/data/web/public/
      #- ./data-web/staging:/data/web/staging/
vdloo commented 6 years ago

Hi @mikebranderhorst, check out this osx readme by @frosit, perhaps that will be more fitting for your situation: https://github.com/frosit/hypernode-docker/tree/master/examples/osx_development

kerrermanisNL commented 6 years ago

FYI it's also possible to get in the docker just by logging into the docker with docker exec and changing to the app user. This might not be the most complete solution, but might be nice for quick access:

docker ps  # Check for docker ID
docker exec -ti <docker_id> /bin/bash
su app

I could run most of the stuff this way, but wasn't able to access the site on hypernode.local.local (though that might not be related, haven't check so far).

mikebranderhorst commented 6 years ago

@kerrermanisNL

If you take a look at my example, I use docker-compose and there is an example with exec, see bash to ~

mikebranderhorst commented 6 years ago

@vdloo

My example use docker-compose and I prefer not to use any other plugins/extensions/apps/programs

The example is provided and working for others to use. Including some basic usage examples. It would be nice to have this in the repo for others. The merged pull request with sync is not needed to work with docker and OSX

frosit commented 6 years ago

Hi @mikebranderhorst docker-sync seemed necessary in my opinion to have acceptable performance. Even the newer caching methods for docker for mac seemed to be too slow, especially with Magento 2. I've tested and compared them all. If your okay with the performance without docker-sync, feel free to send in another PR, maybe others feel te same. I do recommend you to take a look at the link below as it makes a noticeable difference in performance.

https://docs.docker.com/docker-for-mac/osxfs-caching/#examples

I rather not use docker-sync as well, but I haven't found a better alternative (yet).