Skip to content

Instantly share code, notes, and snippets.

@space11
Last active June 15, 2021 09:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save space11/1748cd0413b99f47299c528d727505ca to your computer and use it in GitHub Desktop.
Save space11/1748cd0413b99f47299c528d727505ca to your computer and use it in GitHub Desktop.
Docker Cheat Sheet

Docker Cheat Sheet

Bash into container

Method 1: Use the docker attach Command to Connect to a Running Container

The docker attach command links a local input, output, and error stream to a container. By default, it launches in a bash shell. To connect to a running container, enter the following:

sudo docker attach Container_Name

Copy files to/from a container

# To copy a file from the local file system to a container, use:
docker cp <src-path> <container>:<dest-path> 

#To copy a file from the container to the local file system, use: 
docker cp <container>:<src-path> <local-dest-path>

Quick development Sql Server for deployment

sudo docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=Password_01' \
--name 'sql1-dev' -p 1401:1433 \
-v sql1data:/var/opt/mssql \
-d mcr.microsoft.com/mssql/server:2019-latest

Run MySQL & phpMyAdmin

docker run --name my-own-mysql -e MYSQL_ROOT_PASSWORD=Password_01 -d mysql:8.0.1

docker run --name my-own-phpmyadmin -d --link my-own-mysql:db -p 8081:80 phpmyadmin/phpmyadmin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment