Skip to content

Instantly share code, notes, and snippets.

@ljay79
Last active March 12, 2019 09:53
Show Gist options
  • Save ljay79/e8d839d63003b772d5a5dc2796a45a0e to your computer and use it in GitHub Desktop.
Save ljay79/e8d839d63003b772d5a5dc2796a45a0e to your computer and use it in GitHub Desktop.
Notes: Docker 1st steps
https://docs.docker.com/get-started/part2/#publish-the-image
https://hub.docker.com/r/alexcheng/magento/~/dockerfile/
https://github.com/alexcheng1982/dockerfiles/blob/master/apache-php7/Dockerfile
--------------
preparing windows 10 host drives to use with docker containers easily.
My directory structure:
# win10 host
//storing all docker projects
C:\Users\<User>\Development\docker-projects
//to shares as docker volmues with containers for persistent data
C:\Users\<User>\Development\docker-data
# easy access from WSL (Ubuntu)
/var/opt/docker-data -> /c/Users/<User>/Development/docker-data
/var/opt/docker-projects -> /c/Users/<User>/Development/docker-projects
# using volume in docker-compose.yml
services:
web:
volumes:
- /c/Users/<User>/Development/docker-data/www-data:/var/lib/mysql/data
--------------
# run docker container detached
docker run -d -p 4000:80 ljay/apache2-php7:latest
# mysql server
docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=123456 -d amazon-mysql5:latest -p 3306:3306
---------
create new docker image and push to repo
$ docker build -t apache2-php7 .
$ docker tag apache2-php7 ljay/apache2-php7:latest
$ docker push ljay/apache2-php7:latest
run container
$ docker run -d apache2-php7 [options]
connect connect to running docker container
$ docker exec -i -t 665b4a1e17b6 /bin/bash
############################
# How to remove <none> images after building
# https://forums.docker.com/t/how-to-remove-none-images-after-building/7050
$ docker rmi $(docker images -f "dangling=true" -q)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment