Docker使ったコマンド備忘録

起動終了

docker-compose.ymlのあるパスまで降りて行って

% docker-compose up -d

-d だとデーモンで上がるから起動した後にコマンドプロンプトに復帰できる。

終了は

% docker-compose down

 

今走ってるコンテナのCONTAINER ID

% docker ps

 

コンテナに侵入

% docker ps

で一覧が出た時にここに注目
NAMES
example-app-laravel.test-1

これだったら下記で侵入

% docker-compose exec laravel.test bash

こんな風に変わる

root@xxxxxxxxxxx:/var/www/html#

 

コンテナを出る!

# exit

 

コンテナとローカルでCP

ahaフォルダの中身は空

aha % ll
total 0
drwxr-xr-x 2 t_ft staff 64 7 8 14:55 ./
drwxr-x—+ 30 t_ft staff 960 7 8 14:56 ../

 

コンテナIDを探る

% docker ps
CONTAINER ID       NAMES

immoralsuspicion       example-app-laravel.test-1

※このIDはTX的冗談です

 

コピー実行

% docker cp immoralsuspicion:/var/www/html/storage /Users/myaccount/aha

 

フォルダを指定すると中身も丸っとコピーされるからね。

% ll
total 0
drwxr-xr-x 3 t_ft staff 96 7 8 15:00 ./
drwxr-x—+ 30 t_ft staff 960 7 8 14:58 ../
drwxr-xr-x@ 5 t_ft staff 160 3 9 01:57 storage/

% cd storage

% ll
total 0
drwxr-xr-x@ 5 t_ft staff 160 3 9 01:57 ./
drwxr-xr-x 3 t_ft staff 96 7 8 15:00 ../
drwxr-xr-x@ 4 t_ft staff 128 3 9 01:57 app/
drwxr-xr-x@ 7 t_ft staff 224 3 9 01:57 framework/
drwxr-xr-x@ 3 t_ft staff 96 3 9 01:57 logs/