Skip to content

Instantly share code, notes, and snippets.

@nyaocat
Created January 5, 2017 02:18
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nyaocat/cb1366ab028caeeb56283899555818bf to your computer and use it in GitHub Desktop.
Save nyaocat/cb1366ab028caeeb56283899555818bf to your computer and use it in GitHub Desktop.
#!/bin/bash
# usage: docker-edit container filepath
# License: NYSL
set -eu
TMPFILE=$(mktemp)
trap "rm $TMPFILE" 0
docker cp $1:$2 $TMPFILE
${EDITOR:-vi} $TMPFILE
docker cp $TMPFILE $1:$2
@nyaocat
Copy link
Author

nyaocat commented Jan 5, 2017

docker-edit という名前で $PATH の通っている場所に置くと、

$ docker-edit "コンテナ名" "ファイルパス"

という記述で手元で docker コンテナ内のファイルが編集できる。エディタは環境変数 $EDITOR を参照している。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment