Install and run Sublime Text 3 / 4 text editor with all the packages, dependencies and even license on multiple Linux machines having the same setup can be achieved by running the Sublime Text 4 editor in Docker container.
Clone this Sublime Text 4 with packages, dependencies and license in Docker container with X11 Git repository and build / run instructions following the instructions below.
Setup / Install Instructions
Git clone the repo
mkdir -p ~/git/ictoi/
cd ~/git/ictoi/
git clone https://git.ictoi.io/ictoi/sublime-text-docker.git
Copy your Sublime Text license key
- Portable License Keys
- make sure the key is in the plain text format like:
----- BEGIN LICENSE -----
...
YOUR LICENSE DATA
...
------ END LICENSE ------
sudo cp ~/path-to-your-license-key/License.sublime_license ~/git/ictoi/sublime-text-docker/sublime-text-3/Local/License.sublime_license
Build the container
cd ~/git/ictoi/sublime-text-docker/
sudo docker build --build-arg WORKSPACE_ARG=/home/ori/workspace/ --force-rm -t ictoi/sublime-text:4 .
Test run the container
sudo docker run --name sublime-text-4 -it --rm -e DISPLAY=$DISPLAY -e DISPLAY_WIDTH=1920 -e DISPLAY_HEIGHT=1080 -v /tmp/.X11-unix:/tmp/.X11-unix -v ~/git/:/home/ori/workspace:Z -e WORKSPACE_ENV=/home/ori/workspace/ ictoi/sublime-text:4
Create a .bashrc short
- echo alias to
~/.bash_aliases
echo -e "\nalias subl='sudo docker run --name sublime-text-4 -it --rm -e DISPLAY=$DISPLAY -e DISPLAY_WIDTH=1920 -e DISPLAY_HEIGHT=1080 -v /tmp/.X11-unix:/tmp/.X11-unix -v ~/git/:/home/ori/workspace:Z -e WORKSPACE_ENV=/home/ori/workspace/default.md ictoi/sublime-text:4'" >> ~/.bash_aliases
- reload
~/.bashrc
source ~/.bashrc
Run Sublime Text 4 in the Docker container
subl
Operations with the containers and images
Command | Description |
---|---|
sudo docker images -a | list all even hidden images |
sudo docker stop $(sudo docker ps -aqf "name=sublime*") | stop docker container by sublime* name pattern |
sudo docker rm $(sudo docker ps -a -q) | delete all stopped containers |
sudo docker image rm $(sudo docker image ls --format="{{.ID}}" sublime-text) | remove docker image by sublime-text name |
sudo docker rmi -f $(sudo docker images -q) | delete all / even hidden images |
sudo docker system prune | remove all stopped containers, networks not used by at least one container, dangling images, dangling build cache |
sudo docker cp sublime-text-4:/home/ori/.config/sublime-text-3 /tmp/sublime-text-3/ | copy config files from container to the host |
Notes
$HOME/workspace
is the workspace you’d like to work with- You can mount your own config if you already have one:
-v $HOME/.config/sublime-text-3/:/home/ori/.config/sublime-text-3
Troubleshooting
- For an error
# 'Gtk: cannot open display: :0'
- Set
DISPLAY=your_host_ip:0
or runxhost +
on your host following - Delete the
xhost
byxhost -